54#include "llvm/ADT/STLExtras.h"
55#include "llvm/ADT/StringExtras.h"
56#include "llvm/Support/Casting.h"
57#include "llvm/Support/ConvertUTF.h"
58#include "llvm/Support/SaveAndRestore.h"
59#include "llvm/Support/TypeSize.h"
85 if (TreatUnavailableAsInvalid &&
95 if (isa<UnresolvedUsingIfExistsDecl>(D))
103 if (
const auto *A = D->
getAttr<UnusedAttr>()) {
106 if (A->getSemanticSpelling() != UnusedAttr::CXX11_maybe_unused &&
107 A->getSemanticSpelling() != UnusedAttr::C2x_maybe_unused) {
109 if (DC && !DC->
hasAttr<UnusedAttr>())
110 S.
Diag(Loc, diag::warn_used_but_marked_unused) << D;
119 if (
Decl->isDefaulted()) {
130 auto *Ctor = dyn_cast<CXXConstructorDecl>(
Decl);
131 if (Ctor && Ctor->isInheritingConstructor())
142 if (I->getStorageClass() !=
SC_None)
169 if (!Current->isInlined())
171 if (!Current->isExternallyVisible())
187 if (!DowngradeWarning && UsedFn)
190 S.
Diag(Loc, DowngradeWarning ? diag::ext_internal_in_extern_inline_quiet
191 : diag::ext_internal_in_extern_inline)
206 Diag(DeclBegin, diag::note_convert_inline_to_static)
225 bool ObjCPropertyAccess,
226 bool AvoidPartialAvailabilityChecks,
228 bool SkipTrailingRequiresClause) {
236 Diag(Suppressed.first, Suppressed.second);
247 if (cast<FunctionDecl>(D)->isMain())
248 Diag(Loc, diag::ext_main_used);
255 if (isa<BindingDecl>(D)) {
256 Diag(Loc, diag::err_binding_cannot_appear_in_own_initializer)
259 Diag(Loc, diag::err_auto_variable_cannot_appear_in_own_initializer)
267 if (FD->isDeleted()) {
268 auto *Ctor = dyn_cast<CXXConstructorDecl>(FD);
269 if (Ctor && Ctor->isInheritingConstructor())
270 Diag(Loc, diag::err_deleted_inherited_ctor_use)
272 << Ctor->getInheritedConstructor().getConstructor()->getParent();
274 Diag(Loc, diag::err_deleted_function_use);
287 if (!SkipTrailingRequiresClause && FD->getTrailingRequiresClause()) {
296 diag::err_reference_to_function_with_unsatisfied_constraints)
314 if (
auto *MD = dyn_cast<CXXMethodDecl>(D)) {
316 if (MD->getParent()->isLambda() &&
317 ((isa<CXXConstructorDecl>(MD) &&
318 cast<CXXConstructorDecl>(MD)->isDefaultConstructor()) ||
319 MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator())) {
320 Diag(Loc, diag::warn_cxx17_compat_lambda_def_ctor_assign)
325 auto getReferencedObjCProp = [](
const NamedDecl *D) ->
327 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
328 return MD->findPropertyDecl();
342 auto *DRD = dyn_cast<OMPDeclareReductionDecl>(
CurContext);
345 Diag(Loc, diag::err_omp_wrong_var_in_declare_reduction)
356 if (
LangOpts.OpenMP && isa<VarDecl>(D) &&
358 Diag(Loc, diag::err_omp_declare_mapper_wrong_var)
364 if (
const auto *EmptyD = dyn_cast<UnresolvedUsingIfExistsDecl>(D)) {
365 Diag(Loc, diag::err_use_of_empty_using_if_exists);
366 Diag(EmptyD->getLocation(), diag::note_empty_using_if_exists_here);
371 AvoidPartialAvailabilityChecks, ClassReceiver);
377 if (D->
hasAttr<AvailableOnlyInDefaultEvalMethodAttr>()) {
383 diag::err_type_available_only_in_default_eval_method)
387 if (
auto *VD = dyn_cast<ValueDecl>(D))
393 if (
const auto *VD = dyn_cast<VarDecl>(D))
395 targetDiag(*Locs.begin(), diag::err_thread_unsupported);
398 if (isa<ParmVarDecl>(D) && isa<RequiresExprBodyDecl>(D->
getDeclContext()) &&
403 Diag(Loc, diag::err_requires_expr_parameter_referenced_in_evaluated_context)
418 const SentinelAttr *
attr = D->
getAttr<SentinelAttr>();
423 unsigned numFormalParams;
427 enum CalleeType { CT_Function, CT_Method, CT_Block } calleeType;
430 numFormalParams = MD->param_size();
431 calleeType = CT_Method;
432 }
else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
433 numFormalParams = FD->param_size();
434 calleeType = CT_Function;
435 }
else if (isa<VarDecl>(D)) {
441 calleeType = CT_Function;
444 calleeType = CT_Block;
450 numFormalParams = proto->getNumParams();
462 unsigned nullPos =
attr->getNullPos();
463 assert((nullPos == 0 || nullPos == 1) &&
"invalid null position on sentinel");
464 numFormalParams = (nullPos > numFormalParams ? 0 : numFormalParams - nullPos);
467 unsigned numArgsAfterSentinel =
attr->getSentinel();
471 if (Args.size() < numFormalParams + numArgsAfterSentinel + 1) {
478 Expr *sentinelExpr = Args[Args.size() - numArgsAfterSentinel - 1];
479 if (!sentinelExpr)
return;
488 std::string NullValue;
492 NullValue =
"nullptr";
496 NullValue =
"(void*) 0";
499 Diag(Loc, diag::warn_missing_sentinel) <<
int(calleeType);
501 Diag(MissingNilLoc, diag::warn_missing_sentinel)
525 assert(!Ty.
isNull() &&
"DefaultFunctionArrayConversion - missing type");
529 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
534 CK_FunctionToPointerDecay).
get();
549 CK_ArrayToPointerDecay);
565 if (UO && UO->getOpcode() == UO_Deref &&
566 UO->getSubExpr()->getType()->isPointerType()) {
568 UO->getSubExpr()->getType()->getPointeeType().getAddressSpace();
571 UO->getSubExpr()->IgnoreParenCasts()->isNullPointerConstant(
573 !UO->getType().isVolatileQualified()) {
575 S.
PDiag(diag::warn_indirection_through_null)
576 << UO->getSubExpr()->getSourceRange());
578 S.
PDiag(diag::note_indirection_through_null));
598 BaseType = BaseType->getPointeeType();
610 if (ObjectSetClass) {
654 assert(!T.isNull() &&
"r-value conversion on typeless expression?");
657 if (T->isFunctionType() || T->isArrayType())
664 T->isDependentType() ||
694 SourceRange(OISA->getOpLoc(), OISA->getIsaMemberLoc()),
")");
711 if (T.hasQualifiers())
712 T = T.getUnqualifiedType();
715 if (T->isMemberPointerType() &&
727 Cleanup.setExprNeedsCleanups(
true);
730 Cleanup.setExprNeedsCleanups(
true);
734 CastKind CK = T->isNullPtrType() ? CK_NullToPointer : CK_LValueToRValue;
742 T = Atomic->getValueType().getUnqualifiedType();
769 CK_FunctionToPointerDecay);
792 assert(!Ty.
isNull() &&
"UsualUnaryConversions - missing type");
799 switch (EvalMethod) {
801 llvm_unreachable(
"Unrecognized float evaluation method");
804 llvm_unreachable(
"Float evaluation method should be set by now");
812 CK_FloatingComplexCast)
821 CK_FloatingComplexCast)
869 assert(!Ty.
isNull() &&
"DefaultArgumentPromotion - missing type");
881 if (BTy && (BTy->
getKind() == BuiltinType::Half ||
882 BTy->
getKind() == BuiltinType::Float)) {
885 if (BTy->
getKind() == BuiltinType::Half) {
903 "Unexpected typesize for LongLongTy");
968 if (!Record->hasNonTrivialCopyConstructor() &&
969 !Record->hasNonTrivialMoveConstructor() &&
970 !Record->hasNonTrivialDestructor())
997 PDiag(diag::warn_cxx98_compat_pass_non_pod_arg_to_vararg) << Ty << CT);
1004 PDiag(diag::warn_pass_class_arg_to_vararg)
1012 PDiag(diag::warn_cannot_pass_non_pod_arg_to_vararg)
1019 diag::err_cannot_pass_non_trivial_c_struct_to_vararg)
1023 PDiag(diag::err_cannot_pass_objc_interface_to_vararg)
1038 if (PlaceholderTy->getKind() == BuiltinType::ARCUnbridgedCast &&
1040 (FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>()))) {
1079 if (Call.isInvalid())
1084 if (Comma.isInvalid())
1091 diag::err_call_incomplete_argument))
1108 if (SkipCast)
return false;
1113 CK_FloatingRealToComplex);
1117 CK_IntegralComplexToFloatingComplex);
1135 bool PromotePrecision) {
1140 if (PromotePrecision) {
1145 if (LongerIsComplex)
1157 QualType RHSType,
bool IsCompAssign) {
1182 bool ConvertFloat,
bool ConvertInt) {
1187 CK_IntegralToFloating);
1198 CK_IntegralComplexToFloatingComplex);
1203 CK_FloatingRealToComplex);
1212 QualType RHSType,
bool IsCompAssign) {
1222 else if (!IsCompAssign)
1224 return LHSFloat ? LHSType : RHSType;
1229 if (LHSFloat && RHSFloat) {
1236 assert(order < 0 &&
"illegal float comparison");
1270 QualType LHSElem = LHSComplex ? LHSComplex->getElementType() : LHSType;
1276 if ((&LHSSem != &llvm::APFloat::PPCDoubleDouble() ||
1277 &RHSSem != &llvm::APFloat::IEEEquad()) &&
1278 (&LHSSem != &llvm::APFloat::IEEEquad() ||
1279 &RHSSem != &llvm::APFloat::PPCDoubleDouble()))
1296 CK_IntegralComplexCast);
1302template <PerformCastFn doLHSCast, PerformCastFn doRHSCast>
1305 QualType RHSType,
bool IsCompAssign) {
1310 if (LHSSigned == RHSSigned) {
1313 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1315 }
else if (!IsCompAssign)
1316 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1318 }
else if (order != (LHSSigned ? 1 : -1)) {
1322 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1324 }
else if (!IsCompAssign)
1325 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1332 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1334 }
else if (!IsCompAssign)
1335 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1344 RHS = (*doRHSCast)(S, RHS.
get(), result);
1346 LHS = (*doLHSCast)(S, LHS.
get(), result);
1356 bool IsCompAssign) {
1360 if (LHSComplexInt && RHSComplexInt) {
1365 (S, LHS, RHS, LHSEltType, RHSEltType, IsCompAssign);
1370 if (LHSComplexInt) {
1374 (S, LHS, RHS, LHSEltType, RHSType, IsCompAssign);
1377 CK_IntegralRealToComplex);
1382 assert(RHSComplexInt);
1387 (S, LHS, RHS, LHSType, RHSEltType, IsCompAssign);
1392 CK_IntegralRealToComplex);
1401 assert(BTy &&
"Expected a builtin type.");
1403 switch (BTy->getKind()) {
1404 case BuiltinType::ShortFract:
1405 case BuiltinType::UShortFract:
1406 case BuiltinType::SatShortFract:
1407 case BuiltinType::SatUShortFract:
1409 case BuiltinType::Fract:
1410 case BuiltinType::UFract:
1411 case BuiltinType::SatFract:
1412 case BuiltinType::SatUFract:
1414 case BuiltinType::LongFract:
1415 case BuiltinType::ULongFract:
1416 case BuiltinType::SatLongFract:
1417 case BuiltinType::SatULongFract:
1419 case BuiltinType::ShortAccum:
1420 case BuiltinType::UShortAccum:
1421 case BuiltinType::SatShortAccum:
1422 case BuiltinType::SatUShortAccum:
1424 case BuiltinType::Accum:
1425 case BuiltinType::UAccum:
1426 case BuiltinType::SatAccum:
1427 case BuiltinType::SatUAccum:
1429 case BuiltinType::LongAccum:
1430 case BuiltinType::ULongAccum:
1431 case BuiltinType::SatLongAccum:
1432 case BuiltinType::SatULongAccum:
1435 if (BTy->isInteger())
1437 llvm_unreachable(
"Unexpected fixed point or integer type");
1449 "Expected at least one of the operands to be a fixed point type");
1452 "Special fixed point arithmetic operation conversions are only "
1453 "applied to ints or other fixed point types");
1475 QualType ResultTy = LHSTyRank > RHSTyRank ? LHSTy : RHSTy;
1497 REnum = R->isUnscopedEnumerationType();
1499 if ((!IsCompAssign && LEnum && R->isFloatingType()) ||
1502 ? diag::warn_arith_conv_enum_float_cxx20
1503 : diag::warn_arith_conv_enum_float)
1505 << (
int)ACK << LEnum << L << R;
1506 }
else if (!IsCompAssign && LEnum && REnum &&
1509 if (!L->
castAs<EnumType>()->getDecl()->hasNameForLinkage() ||
1510 !R->castAs<EnumType>()->getDecl()->hasNameForLinkage()) {
1515 ? diag::warn_arith_conv_mixed_anon_enum_types_cxx20
1516 : diag::warn_arith_conv_mixed_anon_enum_types;
1521 ? diag::warn_conditional_mixed_enum_types_cxx20
1522 : diag::warn_conditional_mixed_enum_types;
1527 ? diag::warn_comparison_mixed_enum_types_cxx20
1528 : diag::warn_comparison_mixed_enum_types;
1531 ? diag::warn_arith_conv_mixed_enum_types_cxx20
1532 : diag::warn_arith_conv_mixed_enum_types;
1535 << (
int)ACK << L << R;
1565 LHSType = AtomicLHS->getValueType();
1577 QualType LHSUnpromotedType = LHSType;
1581 if (!LHSBitfieldPromoteTy.
isNull())
1582 LHSType = LHSBitfieldPromoteTy;
1627 bool PredicateIsExpr,
void *ControllingExprOrType,
1629 unsigned NumAssocs = ArgTypes.size();
1630 assert(NumAssocs == ArgExprs.size());
1633 for (
unsigned i = 0; i < NumAssocs; ++i) {
1642 if (!PredicateIsExpr) {
1646 assert(ControllingType &&
"couldn't get the type out of the parser");
1647 ControllingExprOrType = ControllingType;
1651 KeyLoc, DefaultLoc, RParenLoc, PredicateIsExpr, ControllingExprOrType,
1659 bool PredicateIsExpr,
void *ControllingExprOrType,
1661 unsigned NumAssocs = Types.size();
1662 assert(NumAssocs == Exprs.size());
1663 assert(ControllingExprOrType &&
1664 "Must have either a controlling expression or a controlling type");
1666 Expr *ControllingExpr =
nullptr;
1668 if (PredicateIsExpr) {
1675 reinterpret_cast<Expr *
>(ControllingExprOrType));
1678 ControllingExpr = R.
get();
1681 ControllingType =
reinterpret_cast<TypeSourceInfo *
>(ControllingExprOrType);
1682 if (!ControllingType)
1686 bool TypeErrorFound =
false,
1687 IsResultDependent = ControllingExpr
1690 ContainsUnexpandedParameterPack =
1700 diag::warn_side_effects_unevaluated_context);
1702 for (
unsigned i = 0; i < NumAssocs; ++i) {
1703 if (Exprs[i]->containsUnexpandedParameterPack())
1704 ContainsUnexpandedParameterPack =
true;
1707 if (Types[i]->
getType()->containsUnexpandedParameterPack())
1708 ContainsUnexpandedParameterPack =
true;
1710 if (Types[i]->
getType()->isDependentType()) {
1711 IsResultDependent =
true;
1724 if (ControllingExpr && Types[i]->
getType()->isIncompleteType())
1725 D = diag::err_assoc_type_incomplete;
1726 else if (ControllingExpr && !Types[i]->
getType()->isObjectType())
1727 D = diag::err_assoc_type_nonobject;
1728 else if (Types[i]->
getType()->isVariablyModifiedType())
1729 D = diag::err_assoc_type_variably_modified;
1730 else if (ControllingExpr) {
1749 unsigned Reason = 0;
1758 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1759 diag::warn_unreachable_association)
1760 << QT << (Reason - 1);
1764 Diag(Types[i]->getTypeLoc().getBeginLoc(), D)
1765 << Types[i]->getTypeLoc().getSourceRange()
1766 << Types[i]->getType();
1767 TypeErrorFound =
true;
1772 for (
unsigned j = i+1; j < NumAssocs; ++j)
1773 if (Types[j] && !Types[j]->
getType()->isDependentType() &&
1775 Types[j]->getType())) {
1776 Diag(Types[j]->getTypeLoc().getBeginLoc(),
1777 diag::err_assoc_compatible_types)
1778 << Types[j]->getTypeLoc().getSourceRange()
1779 << Types[j]->getType()
1780 << Types[i]->getType();
1781 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1782 diag::note_compat_assoc)
1783 << Types[i]->getTypeLoc().getSourceRange()
1784 << Types[i]->getType();
1785 TypeErrorFound =
true;
1795 if (IsResultDependent) {
1796 if (ControllingExpr)
1798 Types, Exprs, DefaultLoc, RParenLoc,
1799 ContainsUnexpandedParameterPack);
1801 Exprs, DefaultLoc, RParenLoc,
1802 ContainsUnexpandedParameterPack);
1806 unsigned DefaultIndex = -1U;
1810 for (
unsigned i = 0; i < NumAssocs; ++i) {
1813 else if (ControllingExpr &&
1816 Types[i]->getType()))
1817 CompatIndices.push_back(i);
1818 else if (ControllingType &&
1821 Types[i]->getType()))
1822 CompatIndices.push_back(i);
1825 auto GetControllingRangeAndType = [](
Expr *ControllingExpr,
1829 if (ControllingExpr)
1838 return std::make_pair(SR, QT);
1844 if (CompatIndices.size() > 1) {
1845 auto P = GetControllingRangeAndType(ControllingExpr, ControllingType);
1848 << SR <<
P.second << (
unsigned)CompatIndices.size();
1849 for (
unsigned I : CompatIndices) {
1850 Diag(Types[I]->getTypeLoc().getBeginLoc(),
1851 diag::note_compat_assoc)
1852 << Types[I]->getTypeLoc().getSourceRange()
1853 << Types[I]->getType();
1861 if (DefaultIndex == -1U && CompatIndices.size() == 0) {
1862 auto P = GetControllingRangeAndType(ControllingExpr, ControllingType);
1864 Diag(SR.
getBegin(), diag::err_generic_sel_no_match) << SR <<
P.second;
1873 unsigned ResultIndex =
1874 CompatIndices.size() ? CompatIndices[0] : DefaultIndex;
1876 if (ControllingExpr) {
1878 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
1879 ContainsUnexpandedParameterPack, ResultIndex);
1882 Context, KeyLoc, ControllingType, Types, Exprs, DefaultLoc, RParenLoc,
1883 ContainsUnexpandedParameterPack, ResultIndex);
1901 assert(Args.size() <= 2 &&
"too many arguments for literal operator");
1904 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
1905 ArgTy[ArgIdx] = Args[ArgIdx]->getType();
1906 if (ArgTy[ArgIdx]->isArrayType())
1928 if (Literal.hadError)
1932 for (
const Token &
Tok : StringToks)
1937 &StringTokLocs[0], StringTokLocs.size());
1939 if (!Literal.getUDSuffix().empty()) {
1942 Literal.getUDSuffixOffset());
1943 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
1957 assert(!StringToks.empty() &&
"Must have at least one string!");
1960 if (Literal.hadError)
1964 for (
const Token &
Tok : StringToks)
1969 if (Literal.isWide()) {
1972 }
else if (Literal.isUTF8()) {
1976 }
else if (Literal.isUTF16()) {
1979 }
else if (Literal.isUTF32()) {
1982 }
else if (Literal.isPascal()) {
1990 Diag(StringTokLocs.front(), diag::warn_cxx20_compat_utf8_string);
1996 auto RemovalDiag =
PDiag(diag::note_cxx20_compat_utf8_string_remove_u8);
1998 for (
const Token &
Tok : StringToks) {
1999 if (
Tok.
getKind() == tok::utf8_string_literal) {
2008 Diag(RemovalDiagLoc, RemovalDiag);
2016 Kind, Literal.Pascal, StrTy,
2018 StringTokLocs.size());
2019 if (Literal.getUDSuffix().empty())
2026 Literal.getUDSuffixOffset());
2030 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
2055 Expr *Args[] = { Lit, LenArg };
2066 StringTokLocs.back(), &ExplicitArgs);
2074 llvm::APSInt
Value(CharBits, CharIsUnsigned);
2080 for (
unsigned I = 0,
N = Lit->
getLength(); I !=
N; ++I) {
2087 StringTokLocs.back(), &ExplicitArgs);
2091 llvm_unreachable(
"unexpected literal operator lookup result");
2095 llvm_unreachable(
"unexpected literal operator lookup result");
2127 auto *DRE = dyn_cast<DeclRefExpr>(VD->
getInit());
2130 auto *Referee = dyn_cast<VarDecl>(DRE->getDecl());
2131 if (!Referee || !Referee->hasGlobalStorage() ||
2132 Referee->hasAttr<CUDADeviceAttr>())
2138 auto *MD = dyn_cast_or_null<CXXMethodDecl>(S.
CurContext);
2139 if (MD && MD->getParent()->isLambda() &&
2140 MD->getOverloadedOperator() == OO_Call && MD->hasAttr<CUDADeviceAttr>() &&
2162 if (
VarDecl *VD = dyn_cast<VarDecl>(D)) {
2163 if (VD->getType()->isReferenceType() &&
2166 VD->isUsableInConstantExpressions(
Context))
2187 Context, NNS, TemplateKWLoc, D, RefersToCapturedVariable, NameInfo, Ty,
2215 const auto *FD = dyn_cast<FieldDecl>(D);
2216 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(D))
2217 FD = IFD->getAnonField();
2221 if (FD->isBitField())
2227 if (
const auto *BD = dyn_cast<BindingDecl>(D))
2228 if (
const auto *BE = BD->getBinding())
2253 Id.TemplateId->NumArgs);
2259 TemplateArgs = &Buffer;
2262 TemplateArgs =
nullptr;
2269 unsigned DiagnosticID,
unsigned DiagnosticSuggestID) {
2276 SemaRef.
Diag(TypoLoc, diag::err_no_member) << Typo << Ctx
2279 SemaRef.
Diag(TypoLoc, DiagnosticID) << Typo;
2284 bool DroppedSpecifier =
2287 ? diag::note_implicit_param_decl
2288 : diag::note_previous_decl;
2291 SemaRef.
PDiag(NoteID));
2294 << Typo << Ctx << DroppedSpecifier
2296 SemaRef.
PDiag(NoteID));
2311 bool isDefaultArgument =
2315 const auto *CurMethod = dyn_cast<CXXMethodDecl>(
CurContext);
2316 bool isInstance = CurMethod && CurMethod->isInstance() &&
2325 unsigned DiagID = diag::err_found_in_dependent_base;
2326 unsigned NoteID = diag::note_member_declared_at;
2328 DiagID =
getLangOpts().MSVCCompat ? diag::ext_found_later_in_class
2329 : diag::err_found_later_in_class;
2331 DiagID = diag::ext_found_in_dependent_base;
2332 NoteID = diag::note_dependent_member_use;
2348 Diag(D->getLocation(), NoteID);
2357 if (isDefaultArgument && ((*R.
begin())->isCXXInstanceMember())) {
2375 unsigned diagnostic = diag::err_undeclared_var_use;
2376 unsigned diagnostic_suggest = diag::err_undeclared_var_use_suggest;
2380 diagnostic = diag::err_undeclared_use;
2381 diagnostic_suggest = diag::err_undeclared_use_suggest;
2390 if (isa<CXXRecordDecl>(DC)) {
2406 R.
addDecl(Best->FoundDecl.getDecl(), Best->FoundDecl.getAccess());
2423 assert(!ExplicitTemplateArgs &&
2424 "Diagnosing an empty lookup with explicit template args!");
2428 emitEmptyLookupTypoDiagnostic(TC, *this, SS, Name, TypoLoc, Args,
2429 diagnostic, diagnostic_suggest);
2438 bool DroppedSpecifier =
2442 bool AcceptableWithRecovery =
false;
2443 bool AcceptableWithoutRecovery =
false;
2452 dyn_cast<FunctionTemplateDecl>(CD))
2456 else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(CD))
2457 if (!ExplicitTemplateArgs || ExplicitTemplateArgs->
size() == 0)
2463 ND = Best->FoundDecl;
2464 Corrected.setCorrectionDecl(ND);
2468 Corrected.setCorrectionDecl(ND);
2499 AcceptableWithoutRecovery =
true;
2502 if (AcceptableWithRecovery || AcceptableWithoutRecovery) {
2504 ? diag::note_implicit_param_decl
2505 : diag::note_previous_decl;
2508 PDiag(NoteID), AcceptableWithRecovery);
2512 << DroppedSpecifier << SS.
getRange(),
2513 PDiag(NoteID), AcceptableWithRecovery);
2516 return !AcceptableWithRecovery;
2552 else if (
auto *MD = dyn_cast<CXXMethodDecl>(S.
CurContext))
2560 auto DB = S.
Diag(Loc, diag::ext_undeclared_unqual_id_with_dependent_base);
2561 DB << NameInfo.
getName() << RD;
2563 if (!ThisType.
isNull()) {
2566 Context,
nullptr, ThisType,
true,
2568 nullptr, NameInfo, TemplateArgs);
2585 bool HasTrailingLParen,
bool IsAddressOfOperand,
2587 bool IsInlineAsmIdentifier,
Token *KeywordReplacement) {
2588 assert(!(IsAddressOfOperand && HasTrailingLParen) &&
2589 "cannot be direct & operand and have a trailing lparen");
2621 bool DependentID =
false;
2623 Name.getCXXNameType()->isDependentType()) {
2625 }
else if (SS.
isSet()) {
2636 IsAddressOfOperand, TemplateArgs);
2643 if (TemplateKWLoc.
isValid() || TemplateArgs) {
2649 bool MemberOfUnknownSpecialization;
2652 MemberOfUnknownSpecialization, TemplateKWLoc,
2656 if (MemberOfUnknownSpecialization ||
2659 IsAddressOfOperand, TemplateArgs);
2668 IsAddressOfOperand, TemplateArgs);
2672 if (IvarLookupFollowUp) {
2687 if (R.
empty() && HasTrailingLParen && II &&
2697 if (R.
empty() && !ADL) {
2700 TemplateKWLoc, TemplateArgs))
2705 if (IsInlineAsmIdentifier)
2715 "Typo correction callback misconfigured");
2726 std::nullopt, &TE)) {
2727 if (TE && KeywordReplacement) {
2729 auto BestTC = State.Consumer->getNextCorrection();
2730 if (BestTC.isKeyword()) {
2731 auto *II = BestTC.getCorrectionAsIdentifierInfo();
2732 if (State.DiagHandler)
2733 State.DiagHandler(BestTC);
2737 KeywordReplacement->
setLocation(BestTC.getCorrectionRange().getBegin());
2743 return (
Expr*)
nullptr;
2745 State.Consumer->resetCorrectionStream();
2750 assert(!R.
empty() &&
2751 "DiagnoseEmptyLookup returned false but added no results");
2768 assert(!R.
empty() || ADL);
2794 if (!R.
empty() && (*R.
begin())->isCXXClassMember()) {
2795 bool MightBeImplicitMember;
2796 if (!IsAddressOfOperand)
2797 MightBeImplicitMember =
true;
2799 MightBeImplicitMember =
false;
2801 MightBeImplicitMember =
false;
2803 MightBeImplicitMember =
true;
2809 if (MightBeImplicitMember)
2811 R, TemplateArgs, S);
2814 if (TemplateArgs || TemplateKWLoc.
isValid()) {
2822 "There should only be one declaration found.");
2865 if (
const auto *CD = dyn_cast<CXXRecordDecl>(DC))
2866 if (CD->isInvalidDecl())
2877 unsigned DiagID = diag::err_typename_missing;
2879 DiagID = diag::ext_typename_missing;
2881 auto D =
Diag(Loc, DiagID);
2912 if (!R.
empty() && (*R.
begin())->isCXXClassMember() && !IsAddressOfOperand)
2948 LookForIvars =
true;
2949 else if (IsClassMethod)
2950 LookForIvars =
false;
2961 if (IsClassMethod) {
2982 Diag(Loc, diag::warn_ivar_use_hidden) << IV->getDeclName();
2990 Diag(Loc, diag::err_ivar_use_in_class_method) << IV->getDeclName();
3003 "should not reference ivar from this context");
3006 assert(IFace &&
"should not reference ivar from this context");
3071 cast<ObjCIvarDecl>(Ivar.
get()));
3073 if (Lookup.
empty() && II && AllowBuiltinCreation)
3105 const auto *RD = dyn_cast<CXXRecordDecl>(
Member->getDeclContext());
3113 bool PointerConversions =
false;
3114 if (isa<FieldDecl>(
Member)) {
3118 DestRecordType, FromPtrType
3125 PointerConversions =
true;
3127 DestType = DestRecordType;
3128 FromRecordType = FromType;
3130 }
else if (
const auto *Method = dyn_cast<CXXMethodDecl>(
Member)) {
3131 if (Method->isStatic())
3134 DestType = Method->getThisType();
3139 PointerConversions =
true;
3141 FromRecordType = FromType;
3142 DestType = DestRecordType;
3147 if (FromAS != DestAS) {
3152 if (PointerConversions)
3193 if (Qualifier && Qualifier->getAsType()) {
3195 assert(QType->
isRecordType() &&
"lookup done with non-record type");
3205 FromLoc, FromRange, &BasePath))
3208 if (PointerConversions)
3211 VK, &BasePath).
get();
3214 FromRecordType = QRecordType;
3225 FromLoc, FromRange, &BasePath,
3235 bool HasTrailingLParen) {
3237 if (!HasTrailingLParen)
3255 if (D->isCXXClassMember())
3264 if (isa<UsingShadowDecl>(D))
3266 else if (D->getLexicalDeclContext()->isFunctionOrMethod())
3273 if (
const auto *FDecl = dyn_cast<FunctionDecl>(D)) {
3275 if (FDecl->getBuiltinID() && FDecl->isImplicit())
3277 }
else if (!isa<FunctionTemplateDecl>(D))
3290 bool AcceptInvalid) {
3294 if (isa<TypedefNameDecl>(D)) {
3299 if (isa<ObjCInterfaceDecl>(D)) {
3304 if (isa<NamespaceDecl>(D)) {
3316 const auto *FD = dyn_cast<FunctionDecl>(R.
getFoundDecl());
3318 (FD->isCPUDispatchMultiVersion() || FD->isCPUSpecificMultiVersion());
3323 bool AcceptInvalidDecl) {
3364 bool AcceptInvalidDecl) {
3365 assert(D &&
"Cannot refer to a NULL declaration");
3366 assert(!isa<FunctionTemplateDecl>(D) &&
3367 "Cannot refer unambiguously to a function template");
3377 if (
TemplateDecl *Template = dyn_cast<TemplateDecl>(D)) {
3385 if (!isa<ValueDecl, UnresolvedUsingIfExistsDecl>(D)) {
3386 Diag(Loc, diag::err_ref_non_value) << D << SS.
getRange();
3401 if (VD->isInvalidDecl() && !AcceptInvalidDecl)
3407 if (
auto *IndirectField = dyn_cast<IndirectFieldDecl>(VD);
3408 IndirectField && !IndirectField->isCXXClassMember())
3420 type = type.getNonPackExpansionType();
3424#define ABSTRACT_DECL(kind)
3425#define VALUE(type, base)
3426#define DECL(type, base) case Decl::type:
3427#include "clang/AST/DeclNodes.inc"
3428 llvm_unreachable(
"invalid value decl kind");
3431 case Decl::ObjCAtDefsField:
3432 llvm_unreachable(
"forming non-member reference to ivar?");
3436 case Decl::EnumConstant:
3437 case Decl::UnresolvedUsingValue:
3438 case Decl::OMPDeclareReduction:
3439 case Decl::OMPDeclareMapper:
3448 case Decl::IndirectField:
3449 case Decl::ObjCIvar:
3454 type = type.getNonReferenceType();
3460 case Decl::NonTypeTemplateParm: {
3462 type = reftype->getPointeeType();
3472 if (type->isRecordType()) {
3473 type = type.getUnqualifiedType().withConst();
3481 type = type.getUnqualifiedType();
3486 case Decl::VarTemplateSpecialization:
3487 case Decl::VarTemplatePartialSpecialization:
3488 case Decl::Decomposition:
3489 case Decl::OMPCapturedExpr:
3492 type->isVoidType()) {
3498 case Decl::ImplicitParam:
3499 case Decl::ParmVar: {
3502 type = type.getNonReferenceType();
3509 if (!CapturedType.
isNull())
3510 type = CapturedType;
3519 type = type.getNonReferenceType();
3522 case Decl::Function: {
3523 if (
unsigned BID = cast<FunctionDecl>(VD)->getBuiltinID()) {
3552 if (!cast<FunctionDecl>(VD)->hasPrototype() && isa<FunctionProtoType>(fty))
3561 case Decl::CXXDeductionGuide:
3562 llvm_unreachable(
"building reference to deduction guide");
3564 case Decl::MSProperty:
3566 case Decl::TemplateParamObject:
3572 case Decl::UnnamedGlobalConstant:
3576 case Decl::CXXMethod:
3581 dyn_cast<FunctionProtoType>(VD->getType()))
3589 if (cast<CXXMethodDecl>(VD)->isStatic()) {
3595 case Decl::CXXConversion:
3596 case Decl::CXXDestructor:
3597 case Decl::CXXConstructor:
3609 if (VD->isInvalidDecl() && E)
3616 Target.resize(CharByteWidth * (Source.size() + 1));
3617 char *ResultPtr = &Target[0];
3618 const llvm::UTF8 *ErrorPtr;
3620 llvm::ConvertUTF8toWide(CharByteWidth, Source, ResultPtr, ErrorPtr);
3623 Target.resize(ResultPtr - &Target[0]);
3629 Decl *currentDecl =
nullptr;
3631 currentDecl = BSI->TheDecl;
3633 currentDecl = LSI->CallOperator;
3635 currentDecl = CSI->TheCapturedDecl;
3640 Diag(Loc, diag::ext_predef_outside_function);
3646 if (cast<DeclContext>(currentDecl)->isDependentContext())
3652 unsigned Length = Str.length();
3654 llvm::APInt LengthI(32, Length + 1);
3706 default: llvm_unreachable(
"Unknown simple primary expr!");
3728 if (Literal.hadError())
3732 if (Literal.isWide())
3738 else if (Literal.isUTF16())
3740 else if (Literal.isUTF32())
3749 if (Literal.isWide())
3751 else if (Literal.isUTF16())
3753 else if (Literal.isUTF32())
3755 else if (Literal.isUTF8())
3761 if (Literal.getUDSuffix().empty())
3771 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_character_udl));
3789 using llvm::APFloat;
3790 APFloat Val(Format);
3792 APFloat::opStatus result = Literal.GetFloatValue(Val);
3796 if ((result & APFloat::opOverflow) ||
3797 ((result & APFloat::opUnderflow) && Val.isZero())) {
3798 unsigned diagnostic;
3800 if (result & APFloat::opOverflow) {
3801 diagnostic = diag::warn_float_overflow;
3802 APFloat::getLargest(Format).toString(buffer);
3804 diagnostic = diag::warn_float_underflow;
3805 APFloat::getSmallest(Format).toString(buffer);
3808 S.
Diag(Loc, diagnostic)
3810 << StringRef(buffer.data(), buffer.size());
3813 bool isExact = (result == APFloat::opOK);
3818 assert(E &&
"Invalid expression");
3825 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_type) << QT;
3829 llvm::APSInt ValueAPS;
3835 bool ValueIsPositive = ValueAPS.isStrictlyPositive();
3836 if (!ValueIsPositive || ValueAPS.getActiveBits() > 31) {
3837 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_value)
3838 <<
toString(ValueAPS, 10) << ValueIsPositive;
3869 if (Literal.hadError)
3872 if (Literal.hasUDSuffix()) {
3880 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_numeric_udl));
3883 if (Literal.isFloatingLiteral()) {
3908 !Literal.isImaginary)) {
3917 if (Literal.isFloatingLiteral()) {
3921 if (Literal.GetIntegerValue(ResultVal))
3934 unsigned Length = Literal.getUDSuffixOffset();
3941 false, StrTy, &TokLoc, 1);
3952 bool CharIsUnsigned =
Context.
CharTy->isUnsignedIntegerType();
3953 llvm::APSInt
Value(CharBits, CharIsUnsigned);
3954 for (
unsigned I = 0,
N = Literal.getUDSuffixOffset(); I !=
N; ++I) {
3955 Value = TokSpelling[I];
3964 llvm_unreachable(
"unexpected literal operator lookup result");
3970 if (Literal.isFixedPointLiteral()) {
3973 if (Literal.isAccum) {
3974 if (Literal.isHalf) {
3976 }
else if (Literal.isLong) {
3981 }
else if (Literal.isFract) {
3982 if (Literal.isHalf) {
3984 }
else if (Literal.isLong) {
3993 bool isSigned = !Literal.isUnsigned;
3997 llvm::APInt Val(bit_width, 0, isSigned);
3998 bool Overflowed = Literal.GetFixedPointValue(Val, scale);
3999 bool ValIsZero = Val.isZero() && !Overflowed;
4002 if (Literal.isFract && Val == MaxVal + 1 && !ValIsZero)
4008 else if (Val.ugt(MaxVal) || Overflowed)
4013 }
else if (Literal.isFloatingLiteral()) {
4015 if (Literal.isHalf){
4022 }
else if (Literal.isFloat)
4024 else if (Literal.isLong)
4026 else if (Literal.isFloat16)
4028 else if (Literal.isFloat128)
4048 }
else if (!Literal.isIntegerLiteral()) {
4054 if (Literal.isSizeT)
4057 ? diag::warn_cxx20_compat_size_t_suffix
4058 : diag::ext_cxx23_size_t_suffix
4059 : diag::err_cxx23_size_t_suffix);
4067 ? diag::warn_c2x_compat_bitint_suffix
4068 : diag::ext_c2x_bitint_suffix);
4077 unsigned BitsNeeded =
4078 Literal.isBitInt ? llvm::APInt::getSufficientBitsNeeded(
4079 Literal.getLiteralDigits(), Literal.getRadix())
4081 llvm::APInt ResultVal(BitsNeeded, 0);
4083 if (Literal.GetIntegerValue(ResultVal)) {
4089 "long long is not intmax_t?");
4096 bool AllowUnsigned = Literal.isUnsigned || Literal.getRadix() != 10;
4102 if (Literal.MicrosoftInteger) {
4103 if (Literal.MicrosoftInteger == 8 && !Literal.isUnsigned) {
4107 Width = Literal.MicrosoftInteger;
4109 !Literal.isUnsigned);
4115 if (Literal.isBitInt) {
4118 Width = std::max(ResultVal.getActiveBits(), 1u) +
4119 (Literal.isUnsigned ? 0u : 1u);
4123 unsigned int MaxBitIntWidth =
4125 if (Width > MaxBitIntWidth) {
4127 << Literal.isUnsigned;
4128 Width = MaxBitIntWidth;
4135 ResultVal = ResultVal.zextOrTrunc(Width);
4140 if (Literal.isSizeT) {
4141 assert(!Literal.MicrosoftInteger &&
4142 "size_t literals can't be Microsoft literals");
4147 if (ResultVal.isIntN(SizeTSize)) {
4149 if (!Literal.isUnsigned && ResultVal[SizeTSize - 1] == 0)
4151 else if (AllowUnsigned)
4157 if (Ty.
isNull() && !Literal.isLong && !Literal.isLongLong &&
4163 if (ResultVal.isIntN(IntSize)) {
4165 if (!Literal.isUnsigned && ResultVal[IntSize-1] == 0)
4167 else if (AllowUnsigned)
4174 if (Ty.
isNull() && !Literal.isLongLong && !Literal.isSizeT) {
4178 if (ResultVal.isIntN(LongSize)) {
4180 if (!Literal.isUnsigned && ResultVal[LongSize-1] == 0)
4182 else if (AllowUnsigned)
4187 const unsigned LongLongSize =
4192 ? diag::warn_old_implicitly_unsigned_long_cxx
4194 ext_old_implicitly_unsigned_long_cxx
4195 : diag::warn_old_implicitly_unsigned_long)
4196 << (LongLongSize > LongSize ? 0
4205 if (Ty.
isNull() && !Literal.isSizeT) {
4209 if (ResultVal.isIntN(LongLongSize)) {
4213 if (!Literal.isUnsigned && (ResultVal[LongLongSize-1] == 0 ||
4214 (
getLangOpts().MSVCCompat && Literal.isLongLong)))
4216 else if (AllowUnsigned)
4218 Width = LongLongSize;
4224 ? diag::warn_cxx98_compat_longlong
4225 : diag::ext_cxx11_longlong);
4235 if (Literal.isSizeT)
4237 << Literal.isUnsigned;
4240 diag::ext_integer_literal_too_large_for_signed);
4245 if (ResultVal.getBitWidth() != Width)
4246 ResultVal = ResultVal.trunc(Width);
4252 if (Literal.isImaginary) {
4262 assert(E &&
"ActOnParenExpr() missing expr");
4277 if (!(T->isArithmeticType() || T->isVoidType() || T->isVectorType())) {
4278 S.
Diag(Loc, diag::err_vecstep_non_scalar_vector_type)
4283 assert((T->isVoidType() || !T->isIncompleteType()) &&
4284 "Scalar types should always be complete");
4297 if (T->isFunctionType() &&
4298 (TraitKind == UETT_SizeOf || TraitKind == UETT_AlignOf ||
4299 TraitKind == UETT_PreferredAlignOf)) {
4301 S.
Diag(Loc, diag::ext_sizeof_alignof_function_type)
4308 if (T->isVoidType()) {
4309 unsigned DiagID = S.
LangOpts.OpenCL ? diag::err_opencl_sizeof_alignof_type
4310 : diag::ext_sizeof_alignof_void_type;
4325 S.
Diag(Loc, diag::err_sizeof_nonfragile_interface)
4326 << T << (TraitKind == UETT_SizeOf)
4343 const auto *ICE = dyn_cast<ImplicitCastExpr>(E);
4344 if (!ICE || ICE->getCastKind() != CK_ArrayToPointerDecay)
4347 S.
Diag(Loc, diag::warn_sizeof_array_decay) << ICE->getSourceRange()
4349 << ICE->getSubExpr()->getType();
4364 bool IsUnevaluatedOperand =
4365 (ExprKind == UETT_SizeOf || ExprKind == UETT_AlignOf ||
4366 ExprKind == UETT_PreferredAlignOf || ExprKind == UETT_VecStep);
4367 if (IsUnevaluatedOperand) {
4383 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
4385 if (ExprKind == UETT_VecStep)
4407 if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf) {
4410 diag::err_sizeof_alignof_incomplete_or_sizeless_type,
4415 E, diag::err_sizeof_alignof_incomplete_or_sizeless_type,
4434 if (ExprKind == UETT_SizeOf) {
4435 if (
const auto *DeclRef = dyn_cast<DeclRefExpr>(E->
IgnoreParens())) {
4436 if (
const auto *PVD = dyn_cast<ParmVarDecl>(DeclRef->getFoundDecl())) {
4437 QualType OType = PVD->getOriginalType();
4442 Diag(PVD->getLocation(), diag::note_declared_at);
4450 if (
const auto *BO = dyn_cast<BinaryOperator>(E->
IgnoreParens())) {
4467 S.
Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield)
4474 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Inner)) {
4476 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(Inner)) {
4477 D = ME->getMemberDecl();
4497 if (
FieldDecl *FD = dyn_cast_or_null<FieldDecl>(D)) {
4500 if (!FD->getParent()->isCompleteDefinition()) {
4501 S.
Diag(E->
getExprLoc(), diag::err_alignof_member_of_incomplete_type)
4510 if (!FD->getType()->isReferenceType())
4529 assert(T->isVariablyModifiedType());
4530 assert(CSI !=
nullptr);
4534 const Type *Ty = T.getTypePtr();
4536#define TYPE(Class, Base)
4537#define ABSTRACT_TYPE(Class, Base)
4538#define NON_CANONICAL_TYPE(Class, Base)
4539#define DEPENDENT_TYPE(Class, Base) case Type::Class:
4540#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base)
4541#include "clang/AST/TypeNodes.inc"
4548 case Type::ExtVector:
4549 case Type::ConstantMatrix:
4552 case Type::TemplateSpecialization:
4553 case Type::ObjCObject:
4554 case Type::ObjCInterface:
4555 case Type::ObjCObjectPointer:
4556 case Type::ObjCTypeParam:
4559 llvm_unreachable(
"type class is never variably-modified!");
4560 case Type::Elaborated:
4563 case Type::Adjusted:
4572 case Type::BlockPointer:
4575 case Type::LValueReference:
4576 case Type::RValueReference:
4579 case Type::MemberPointer:
4582 case Type::ConstantArray:
4583 case Type::IncompleteArray:
4587 case Type::VariableArray: {
4595 (isa<CapturedRegionScopeInfo>(CSI) || isa<LambdaScopeInfo>(CSI)))
4601 case Type::FunctionProto:
4602 case Type::FunctionNoProto:
4607 case Type::UnaryTransform:
4608 case Type::Attributed:
4609 case Type::BTFTagAttributed:
4610 case Type::SubstTemplateTypeParm:
4611 case Type::MacroQualified:
4613 T = T.getSingleStepDesugaredType(Context);
4618 case Type::Decltype:
4625 case Type::DeducedTemplateSpecialization:
4628 case Type::TypeOfExpr:
4635 }
while (!T.isNull() && T->isVariablyModifiedType());
4673 if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf ||
4674 ExprKind == UETT_OpenMPRequiredSimdAlign)
4677 if (ExprKind == UETT_VecStep)
4686 OpLoc, ExprType, diag::err_sizeof_alignof_incomplete_or_sizeless_type,
4691 Diag(OpLoc, diag::err_sizeof_alignof_function_type) << KWName << ExprRange;
4699 Diag(OpLoc, diag::err_wasm_table_invalid_uett_operand)
4713 auto *CSI = dyn_cast<CapturingScopeInfo>(*I);
4717 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(CSI))
4718 DC = LSI->CallOperator;
4719 else if (
auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
4720 DC = CRSI->TheCapturedDecl;
4721 else if (
auto *BSI = dyn_cast<BlockScopeInfo>(CSI))
4745 if (!T->isDependentType() &&
4776 }
else if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf) {
4778 }
else if (ExprKind == UETT_VecStep) {
4780 }
else if (ExprKind == UETT_OpenMPRequiredSimdAlign) {
4784 Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 0;
4830 UETT_AlignOf, KWName);
4850 if (
V.get()->isTypeDependent())
4862 return CT->getElementType();
4865 if (
V.get()->getType()->isArithmeticType())
4866 return V.get()->getType();
4871 if (PR.
get() !=
V.get()) {
4877 S.
Diag(Loc, diag::err_realimag_invalid_type) <<
V.get()->getType()
4878 << (IsReal ?
"__real" :
"__imag");
4889 default: llvm_unreachable(
"Unknown unary op!");
4890 case tok::plusplus: Opc = UO_PostInc;
break;
4891 case tok::minusminus: Opc = UO_PostDec;
break;
4910 !S.
LangOpts.ObjCSubscriptingLegacyRuntime)
4913 S.
Diag(opLoc, diag::err_arithmetic_nonfragile_interface)
4920 auto *BaseNoParens =
Base->IgnoreParens();
4921 if (
auto *MSProp = dyn_cast<MSPropertyRefExpr>(BaseNoParens))
4922 return MSProp->getPropertyDecl()->getType()->isArrayType();
4943 if (RTy->isIntegralOrUnscopedEnumerationType()) {
4945 Result = PT->getPointeeType();
4947 Result = AT->getElementType();
4950 Result = PT->getPointeeType();
4952 Result = AT->getElementType();
4972 if (isa<ParenListExpr>(base)) {
4976 base = result.
get();
4983 auto CheckAndReportCommaError = [
this, base, rbLoc](
Expr *E) {
4984 if (isa<BinaryOperator>(E) && cast<BinaryOperator>(E)->isCommaOp()) {
4985 Diag(E->getExprLoc(), diag::err_matrix_subscript_comma)
4995 !isa<MatrixSubscriptExpr>(base)) {
4996 Diag(base->
getExprLoc(), diag::err_matrix_separate_incomplete_index)
5002 auto *matSubscriptE = dyn_cast<MatrixSubscriptExpr>(base);
5003 if (matSubscriptE) {
5004 assert(ArgExprs.size() == 1);
5005 if (CheckAndReportCommaError(ArgExprs.front()))
5008 assert(matSubscriptE->isIncomplete() &&
5009 "base has to be an incomplete matrix subscript");
5011 matSubscriptE->getRowIdx(),
5012 ArgExprs.front(), rbLoc);
5025 bool IsMSPropertySubscript =
false;
5028 if (!IsMSPropertySubscript) {
5032 base = result.
get();
5038 assert(ArgExprs.size() == 1);
5039 if (CheckAndReportCommaError(ArgExprs.front()))
5047 Expr *idx = ArgExprs[0];
5048 if ((isa<BinaryOperator>(idx) && cast<BinaryOperator>(idx)->isCommaOp()) ||
5049 (isa<CXXOperatorCallExpr>(idx) &&
5050 cast<CXXOperatorCallExpr>(idx)->getOperator() == OO_Comma)) {
5056 if (ArgExprs.size() == 1 &&
5057 ArgExprs[0]->getType()->isNonOverloadPlaceholderType()) {
5061 ArgExprs[0] = result.
get();
5071 !isa<PackExpansionExpr>(ArgExprs[0])) {
5073 base, ArgExprs.front(),
5086 if (IsMSPropertySubscript) {
5087 assert(ArgExprs.size() == 1);
5105 (ArgExprs.size() != 1 || isa<PackExpansionExpr>(ArgExprs[0]) ||
5106 ArgExprs[0]->getType()->isRecordType())))) {
5113 if (!Res.
isInvalid() && isa<ArraySubscriptExpr>(Res.
get()))
5114 CheckSubscriptAccessOfNoDeref(cast<ArraySubscriptExpr>(Res.
get()));
5124 return InitSeq.
Perform(*
this, Entity, Kind, E);
5138 RowIdx = RowR.
get();
5153 ColumnIdx = ColumnR.
get();
5158 auto IsIndexValid = [&](
Expr *IndexExpr,
unsigned Dim,
5159 bool IsColumnIdx) ->
Expr * {
5167 if (std::optional<llvm::APSInt> Idx =
5169 if ((*Idx < 0 || *Idx >= Dim)) {
5171 << IsColumnIdx << Dim;
5179 "should be able to convert any integer type to size type");
5180 return ConvExpr.
get();
5184 RowIdx = IsIndexValid(RowIdx, MTy->getNumRows(),
false);
5185 ColumnIdx = IsIndexValid(ColumnIdx, MTy->getNumColumns(),
true);
5186 if (!RowIdx || !ColumnIdx)
5190 MTy->getElementType(), RBLoc);
5193void Sema::CheckAddressOfNoDeref(
const Expr *E) {
5200 while ((
Member = dyn_cast<MemberExpr>(StrippedExpr)) && !
Member->isArrow())
5203 LastRecord.PossibleDerefs.erase(StrippedExpr);
5214 if (isa<ArrayType>(ResultTy))
5217 if (ResultTy->
hasAttr(attr::NoDeref)) {
5218 LastRecord.PossibleDerefs.insert(E);
5226 if (!(isa<ArrayType>(BaseTy) || isa<PointerType>(BaseTy)))
5231 while ((
Member = dyn_cast<MemberExpr>(
Base->IgnoreParenCasts())) &&
5235 if (
const auto *Ptr = dyn_cast<PointerType>(
Base->getType())) {
5236 if (Ptr->getPointeeType()->hasAttr(attr::NoDeref))
5237 LastRecord.PossibleDerefs.insert(E);
5247 if (
Base->hasPlaceholderType() &&
5248 !
Base->hasPlaceholderType(BuiltinType::OMPArraySection)) {
5261 LowerBound =
Result.get();
5283 if (
Base->isTypeDependent() ||
5290 OK_Ordinary, ColonLocFirst, ColonLocSecond, RBLoc);
5302 Diag(
Base->getExprLoc(), diag::err_omp_typecheck_section_value)
5303 <<
Base->getSourceRange());
5309 if (Res.isInvalid())
5311 diag::err_omp_typecheck_section_not_integer)
5313 LowerBound = Res.get();
5323 if (Res.isInvalid())
5325 diag::err_omp_typecheck_section_not_integer)
5339 diag::err_omp_typecheck_section_not_integer)
5354 Diag(
Base->getExprLoc(), diag::err_omp_section_function_type)
5355 << ResultTy <<
Base->getSourceRange();
5360 diag::err_omp_section_incomplete_type,
Base))
5368 llvm::APSInt LowerBoundValue =
Result.Val.getInt();
5369 if (LowerBoundValue.isNegative()) {
5370 Diag(LowerBound->
getExprLoc(), diag::err_omp_section_not_subset_of_array)
5382 llvm::APSInt LengthValue =
Result.Val.getInt();
5383 if (LengthValue.isNegative()) {
5384 Diag(Length->
getExprLoc(), diag::err_omp_section_length_negative)
5390 }
else if (ColonLocFirst.
isValid() &&
5396 Diag(ColonLocFirst, diag::err_omp_section_length_undefined)
5406 llvm::APSInt StrideValue =
Result.Val.getInt();
5407 if (!StrideValue.isStrictlyPositive()) {
5408 Diag(Stride->
getExprLoc(), diag::err_omp_section_stride_non_positive)
5416 if (!
Base->hasPlaceholderType(BuiltinType::OMPArraySection)) {
5424 OK_Ordinary, ColonLocFirst, ColonLocSecond, RBLoc);
5431 if (
Base->hasPlaceholderType()) {
5445 LParenLoc, RParenLoc, Dims, Brackets);
5447 (!
Base->isTypeDependent() &&
5450 diag::err_omp_non_pointer_type_array_shaping_base)
5451 <<
Base->getSourceRange());
5454 bool ErrorFound =
false;
5455 for (
Expr *Dim : Dims) {
5456 if (Dim->hasPlaceholderType()) {
5458 if (
Result.isInvalid()) {
5463 if (
Result.isInvalid()) {
5469 if (!Dim->isTypeDependent()) {
5472 if (
Result.isInvalid()) {
5474 Diag(Dim->getExprLoc(), diag::err_omp_typecheck_shaping_not_integer)
5475 << Dim->getSourceRange();
5480 if (!Dim->isValueDependent() && Dim->EvaluateAsInt(EvResult,
Context)) {
5485 if (!
Value.isStrictlyPositive()) {
5486 Diag(Dim->getExprLoc(), diag::err_omp_shaping_dimension_not_positive)
5488 << Dim->getSourceRange();
5494 NewDims.push_back(Dim);
5499 LParenLoc, RParenLoc, NewDims, Brackets);
5506 bool IsCorrect =
true;
5511 if (!D.Type.getAsOpaquePtr()) {
5516 StartLoc = D.DeclIdentLoc;
5522 bool IsDeclTyDependent = DeclTy->isDependentType() ||
5523 DeclTy->containsUnexpandedParameterPack() ||
5524 DeclTy->isInstantiationDependentType();
5525 if (!IsDeclTyDependent) {
5526 if (!DeclTy->isIntegralType(
Context) && !DeclTy->isAnyPointerType()) {
5529 Diag(StartLoc, diag::err_omp_iterator_not_integral_or_pointer)
5534 if (DeclTy.isConstant(
Context)) {
5537 Diag(StartLoc, diag::err_omp_iterator_not_integral_or_pointer)
5545 assert(D.DeclIdent &&
"Identifier expected.");
5549 D.DeclIdent, DeclTy, TInfo,
SC_None);
5563 Diag(D.DeclIdentLoc, diag::err_redefinition) << VD->getDeclName();
5576 if (!IsDeclTyDependent &&
Begin && !
Begin->isTypeDependent()) {
5581 Expr *End = D.Range.End;
5582 if (!IsDeclTyDependent && End && !End->isTypeDependent()) {
5586 Expr *Step = D.Range.Step;
5589 Diag(Step->
getExprLoc(), diag::err_omp_iterator_step_not_integral)
5594 std::optional<llvm::APSInt>
Result =
5600 Diag(Step->
getExprLoc(), diag::err_omp_iterator_step_constant_zero)
5606 if (!
Begin || !End || !IsCorrect) {
5622 if (
Decl *ID = D.IteratorDecl)
5623 ID->setInvalidDecl();
5666 D.Range.Begin, D.Range.End);
5718 D.IteratorDecl->getBeginLoc(),
nullptr,
5720 CounterVD->setImplicit();
5723 D.IteratorDecl->getBeginLoc());
5729 D.AssignmentLoc, BO_Mul,
5746 cast<VarDecl>(D.IteratorDecl)->getType(),
VK_LValue,
5747 D.IteratorDecl->getBeginLoc());
5762 if (!CounterUpdateRes.
isUsable()) {
5768 if (!CounterUpdateRes.
isUsable()) {
5779 Helpers.assign(ID.size(), {});
5784 if (
Decl *ID = D.IteratorDecl)
5785 ID->setInvalidDecl();
5790 LLoc, RLoc, ID, Helpers);
5805 for (
auto *Op : {LHSExp, RHSExp}) {
5806 Op = Op->IgnoreImplicit();
5807 if (Op->getType()->isArrayType() && !Op->isLValue())
5830 Expr *BaseExpr, *IndexExpr;
5865 Diag(LLoc, diag::err_subscript_nonfragile_interface)
5877 LHSExp = Materialized.
get();
5883 ResultType = VTy->getElementType();
5885 Qualifiers BaseQuals = BaseType.getQualifiers();
5887 Qualifiers Combined = BaseQuals + MemberQuals;
5888 if (Combined != MemberQuals)
5903 LHSExp = Materialized.
get();
5912 Qualifiers BaseQuals = BaseType.getQualifiers();
5914 Qualifiers Combined = BaseQuals + MemberQuals;
5915 if (Combined != MemberQuals)
5926 CK_ArrayToPointerDecay).
get();
5932 }
else if (RHSTy->isArrayType()) {
5937 CK_ArrayToPointerDecay).
get();
5944 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_value)
5949 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_not_integer)
5969 Diag(LLoc, diag::ext_gnu_subscript_void_type)
5980 diag::err_subscript_incomplete_or_sizeless_type, BaseExpr))
5993 auto *CSI = dyn_cast<CapturingScopeInfo>(*I);
5997 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(CSI))
5998 DC = LSI->CallOperator;
5999 else if (
auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
6000 DC = CRSI->TheCapturedDecl;
6001 else if (
auto *BSI = dyn_cast<BlockScopeInfo>(CSI))
6019 bool SkipImmediateInvocations) {
6020 if (Param->hasUnparsedDefaultArg()) {
6021 assert(!RewrittenInit &&
"Should not have a rewritten init expression yet");
6025 Diag(Param->getBeginLoc(), diag::err_recursive_default_argument) << FD;
6026 Diag(CallLoc, diag::note_recursive_default_argument_used_here);
6027 Param->setInvalidDecl();
6031 Diag(CallLoc, diag::err_use_of_default_argument_to_function_declared_later)
6034 diag::note_default_argument_declared_here);
6038 if (Param->hasUninstantiatedDefaultArg()) {
6039 assert(!RewrittenInit &&
"Should not have a rewitten init expression yet");
6044 Expr *Init = RewrittenInit ? RewrittenInit : Param->getInit();
6045 assert(Init &&
"default argument but no initializer?");
6054 if (
auto *InitWithCleanup = dyn_cast<ExprWithCleanups>(Init)) {
6057 Cleanup.setExprNeedsCleanups(InitWithCleanup->cleanupsHaveSideEffects());
6061 assert(!InitWithCleanup->getNumObjects() &&
6062 "default argument expression has capturing blocks?");
6075 SkipImmediateInvocations;
6086 bool HasImmediateCalls =
false;
6091 HasImmediateCalls |= FD->isImmediateFunction();
6100 HasImmediateCalls =
true;
6121 return TraverseStmt(E->
getExpr());
6125 return TraverseStmt(E->
getExpr());
6150 assert(Param->hasDefaultArg() &&
"can't build nonexistent default arg");
6154 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
6155 InitializationContext =
6157 if (!InitializationContext.has_value())
6158 InitializationContext.emplace(CallLoc, Param,
CurContext);
6160 if (!Init && !Param->hasUnparsedDefaultArg()) {
6175 if (Param->hasUninstantiatedDefaultArg()) {
6184 if (!NestedDefaultChecking)
6185 V.TraverseDecl(Param);
6186 if (
V.HasImmediateCalls) {
6192 Res = Immediate.TransformInitializer(Param->getInit(),
6206 CallLoc, FD, Param, Init,
6207 NestedDefaultChecking))
6211 Init, InitializationContext->Context);
6215 assert(Field->hasInClassInitializer());
6218 if (Field->isInvalidDecl())
6225 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
6226 InitializationContext =
6228 if (!InitializationContext.has_value())
6229 InitializationContext.emplace(Loc, Field,
CurContext);
6231 Expr *Init =
nullptr;
6238 if (!Field->getInClassInitializer()) {
6244 ClassPattern->
lookup(Field->getDeclName());
6247 for (
auto *L : Lookup) {
6248 if ((Pattern = dyn_cast<FieldDecl>(L)))
6251 assert(Pattern &&
"We must have set the Pattern!");
6255 Field->setInvalidDecl();
6267 if (!NestedDefaultChecking)
6268 V.TraverseDecl(Field);
6269 if (
V.HasImmediateCalls) {
6273 NestedDefaultChecking;
6278 Res = Immediate.TransformInitializer(Field->getInClassInitializer(),
6284 Field->setInvalidDecl();
6290 if (Field->getInClassInitializer()) {
6291 Expr *E = Init ? Init : Field->getInClassInitializer();
6292 if (!NestedDefaultChecking)
6300 if (Res.isInvalid()) {
6301 Field->setInvalidDecl();
6307 Field, InitializationContext->Context,
6326 Diag(Loc, diag::err_default_member_initializer_not_yet_parsed)
6327 << OutermostClass << Field;
6328 Diag(Field->getEndLoc(),
6329 diag::note_default_member_initializer_not_yet_parsed);
6332 Field->setInvalidDecl();
6340 if (isa_and_nonnull<CXXConstructorDecl>(FDecl))
6345 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
6346 if (Method->isInstance())
6361 FunctionName(FuncName) {}
6363 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
6372 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
6373 return std::make_unique<FunctionCallCCC>(*
this);
6393 if (
NamedDecl *ND = Corrected.getFoundDecl()) {
6394 if (Corrected.isOverloaded()) {
6404 ND = Best->FoundDecl;
6405 Corrected.setCorrectionDecl(ND);
6411 ND = ND->getUnderlyingDecl();
6412 if (isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND))
6431 bool IsExecConfig) {
6450 if (Args.size() < NumParams) {
6451 if (Args.size() < MinArgs) {
6456 ? diag::err_typecheck_call_too_few_args_suggest
6457 : diag::err_typecheck_call_too_few_args_at_least_suggest;
6459 <<
static_cast<unsigned>(Args.size())
6464 ? diag::err_typecheck_call_too_few_args_one
6465 : diag::err_typecheck_call_too_few_args_at_least_one)
6469 ? diag::err_typecheck_call_too_few_args
6470 : diag::err_typecheck_call_too_few_args_at_least)
6471 << FnKind << MinArgs << static_cast<unsigned>(Args.size())
6475 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
6483 assert((Call->getNumArgs() == NumParams) &&
6484 "We should have reserved space for the default arguments before!");
6489 if (Args.size() > NumParams) {
6495 ? diag::err_typecheck_call_too_many_args_suggest
6496 : diag::err_typecheck_call_too_many_args_at_most_suggest;
6498 <<
static_cast<unsigned>(Args.size())
6500 }
else if (NumParams == 1 && FDecl &&
6502 Diag(Args[NumParams]->getBeginLoc(),
6503 MinArgs == NumParams
6504 ? diag::err_typecheck_call_too_many_args_one
6505 : diag::err_typecheck_call_too_many_args_at_most_one)
6509 Args.back()->getEndLoc());
6511 Diag(Args[NumParams]->getBeginLoc(),
6512 MinArgs == NumParams
6513 ? diag::err_typecheck_call_too_many_args
6514 : diag::err_typecheck_call_too_many_args_at_most)
6515 << FnKind << NumParams << static_cast<unsigned>(Args.size())
6518 Args.back()->getEndLoc());
6521 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
6526 Call->shrinkNumArgs(NumParams);
6537 unsigned TotalNumArgs = AllArgs.size();
6538 for (
unsigned i = 0; i < TotalNumArgs; ++i)
6539 Call->setArg(i, AllArgs[i]);
6541 Call->computeDependence();
6550 bool IsListInitialization) {
6555 for (
unsigned i = FirstParam; i < NumParams; i++) {
6560 if (ArgIx < Args.size()) {
6561 Arg = Args[ArgIx++];
6564 diag::err_call_incomplete_argument, Arg))
6568 bool CFAudited =
false;
6570 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
6571 (!Param || !Param->hasAttr<CFConsumedAttr>()))
6574 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
6575 (!Param || !Param->hasAttr<CFConsumedAttr>()))
6581 BE->getBlockDecl()->setDoesNotEscape();
6594 Entity,
SourceLocation(), Arg, IsListInitialization, AllowExplicit);
6600 assert(Param &&
"can't use default arguments without a known callee");
6612 CheckArrayAccess(Arg);
6617 AllArgs.push_back(Arg);
6626 for (
Expr *A : Args.slice(ArgIx)) {
6630 AllArgs.push_back(arg.get());
6635 for (
Expr *A : Args.slice(ArgIx)) {
6638 AllArgs.push_back(Arg.
get());
6643 for (
Expr *A : Args.slice(ArgIx))
6644 CheckArrayAccess(A);
6652 TL = DTL.getOriginalLoc();
6655 << ATL.getLocalSourceRange();
6669 const Expr *ArgExpr) {
6674 QualType OrigTy = Param->getOriginalType();
6699 Diag(CallLoc, diag::warn_static_array_too_small)
6708 std::optional<CharUnits> ArgSize =
6710 std::optional<CharUnits> ParmSize =
6712 if (ArgSize && ParmSize && *ArgSize < *ParmSize) {
6713 Diag(CallLoc, diag::warn_static_array_too_small)
6715 << (
unsigned)ParmSize->getQuantity() << 1;
6728 const BuiltinType *placeholder = dyn_cast<BuiltinType>(type);
6729 if (!placeholder)
return false;
6731 switch (placeholder->
getKind()) {
6733#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
6734 case BuiltinType::Id:
6735#include "clang/Basic/OpenCLImageTypes.def"
6736#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
6737 case BuiltinType::Id:
6738#include "clang/Basic/OpenCLExtensionTypes.def"
6741#define SVE_TYPE(Name, Id, SingletonId) \
6742 case BuiltinType::Id:
6743#include "clang/Basic/AArch64SVEACLETypes.def"
6744#define PPC_VECTOR_TYPE(Name, Id, Size) \
6745 case BuiltinType::Id:
6746#include "clang/Basic/PPCTypes.def"
6747#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
6748#include "clang/Basic/RISCVVTypes.def"
6749#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
6750#include "clang/Basic/WebAssemblyReferenceTypes.def"
6751#define PLACEHOLDER_TYPE(ID, SINGLETON_ID)
6752#define BUILTIN_TYPE(ID, SINGLETON_ID) case BuiltinType::ID:
6753#include "clang/AST/BuiltinTypes.def"
6758 case BuiltinType::Overload:
6763 case BuiltinType::ARCUnbridgedCast:
6767 case BuiltinType::PseudoObject:
6772 case BuiltinType::UnknownAny:
6776 case BuiltinType::BoundMember:
6777 case BuiltinType::BuiltinFn:
6778 case BuiltinType::IncompleteMatrixIdx:
6779 case BuiltinType::OMPArraySection:
6780 case BuiltinType::OMPArrayShaping:
6781 case BuiltinType::OMPIterator:
6785 llvm_unreachable(
"bad builtin type kind");
6793 bool hasInvalid =
false;
6794 for (
size_t i = 0, e = args.size(); i != e; i++) {
6797 if (result.
isInvalid()) hasInvalid =
true;
6798 else args[i] = result.
get();
6826 bool NeedsNewDecl =
false;
6839 if (!ParamType->isPointerType() || ParamType.hasAddressSpace() ||
6840 !ArgType->isPointerType() ||
6841 !ArgType->getPointeeType().hasAddressSpace() ||
6843 OverloadParams.push_back(ParamType);
6851 NeedsNewDecl =
true;
6852 LangAS AS = ArgType->getPointeeType().getAddressSpace();
6864 OverloadParams, EPI);
6874 for (
unsigned i = 0, e = FT->
getNumParams(); i != e; ++i) {
6881 Params.push_back(Parm);
6883 OverloadDecl->setParams(Params);
6885 return OverloadDecl;
6896 !Callee->isVariadic())
6898 if (Callee->getMinRequiredArguments() > ArgExprs.size())
6901 if (
const EnableIfAttr *
Attr =
6904 isa<CXXMethodDecl>(Callee)
6905 ? diag::err_ovl_no_viable_member_function_in_call
6906 : diag::err_ovl_no_viable_function_in_call)
6907 << Callee << Callee->getSourceRange();
6908 S.
Diag(Callee->getLocation(),
6909 diag::note_ovl_candidate_disabled_by_function_cond_attr)
6910 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
6918 const auto GetFunctionLevelDCIfCXXClass =
6926 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DC))
6927 return MD->
getParent()->getCanonicalDecl();
6930 if (
const auto *RD = dyn_cast<CXXRecordDecl>(DC))
6931 return RD->getCanonicalDecl();
6938 const CXXRecordDecl *
const CurParentClass = GetFunctionLevelDCIfCXXClass(S);
6939 if (!CurParentClass)
6946 assert(NamingClass &&
"Must have naming class even for implicit access");
6952 return CurParentClass == NamingClass ||
7000 if (Call->getNumArgs() != 1)
7003 Expr *E = Call->getCallee()->IgnoreParenImpCasts();
7004 if (!E || isa<UnresolvedLookupExpr>(E))
7006 DeclRefExpr *DRE = dyn_cast_or_null<DeclRefExpr>(E);
7019 if (BuiltinID != Builtin::BImove && BuiltinID != Builtin::BIforward)
7022 S.
Diag(DRE->
getLocation(), diag::warn_unqualified_call_to_std_cast_function)
7033 if (Call.isInvalid())
7038 if (
auto *ULE = dyn_cast<UnresolvedLookupExpr>(Fn)) {
7039 if (ULE->hasExplicitTemplateArgs() &&
7040 ULE->decls_begin() == ULE->decls_end()) {
7042 ? diag::warn_cxx17_compat_adl_only_template_id
7043 : diag::ext_adl_only_template_id)
7052 CallExpr *CE = dyn_cast<CallExpr>(Call.get());
7064 Expr *ExecConfig,
bool IsExecConfig,
7065 bool AllowRecovery) {
7076 if (isa<CXXPseudoDestructorExpr>(Fn)) {
7077 if (!ArgExprs.empty()) {
7082 ArgExprs.back()->getEndLoc()));
7099 cast<CallExpr>(ExecConfig), ArgExprs,
7105 *
this, dyn_cast<UnresolvedMemberExpr>(Fn->
IgnoreParens()),
7126 RParenLoc, ExecConfig, IsExecConfig,
7143 Scope, Fn, ULE, LParenLoc, ArgExprs, RParenLoc, ExecConfig,
7146 RParenLoc, ExecConfig, IsExecConfig,
7160 bool CallingNDeclIndirectly =
false;
7162 if (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(NakedFn)) {
7163 if (UnOp->getOpcode() == UO_AddrOf) {
7164 CallingNDeclIndirectly =
true;
7169 if (
auto *DRE = dyn_cast<DeclRefExpr>(NakedFn)) {
7170 NDecl = DRE->getDecl();
7183 nullptr, DRE->isNonOdrUse());
7186 }
else if (
auto *ME = dyn_cast<MemberExpr>(NakedFn))
7187 NDecl = ME->getMemberDecl();
7189 if (
FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(NDecl)) {
7203 FD->getBuiltinID()) {
7204 for (
unsigned Idx = 0; Idx < FD->param_size(); ++Idx) {
7206 if (!ArgExprs[Idx] || !Param || !Param->getType()->isPointerType() ||
7207 !ArgExprs[Idx]->getType()->isPointerType())
7211 auto ArgTy = ArgExprs[Idx]->getType();
7212 auto ArgPtTy = ArgTy->getPointeeType();
7213 auto ArgAS = ArgPtTy.getAddressSpace();
7216 bool NeedImplicitASC =
7221 if (!NeedImplicitASC)
7225 if (ArgExprs[Idx]->isGLValue()) {
7232 Qualifiers ArgPtQuals = ArgPtTy.getQualifiers();
7242 CK_AddressSpaceConversion)
7252 llvm::any_of(ArgExprs,
7253 [](
clang::Expr *E) { return E->containsErrors(); })) &&
7254 "should only occur in error-recovery path.");
7259 ExecConfig, IsExecConfig);
7272 assert(BuiltInDecl &&
"failed to find builtin declaration");
7276 assert(DeclRef.
isUsable() &&
"Builtin reference cannot fail");
7281 assert(!Call.isInvalid() &&
"Call to builtin cannot fail!");
7306 Diag(BuiltinLoc, diag::err_invalid_astype_of_different_size)
7335 FunctionDecl *FDecl = dyn_cast_or_null<FunctionDecl>(NDecl);
7336 unsigned BuiltinID = (FDecl ? FDecl->
getBuiltinID() : 0);
7339 if (FDecl && FDecl->
hasAttr<AnyX86InterruptAttr>()) {
7352 if (Caller->hasAttr<ARMInterruptAttr>()) {
7354 if (VFP && (!FDecl || !FDecl->
hasAttr<ARMInterruptAttr>())) {
7355 Diag(Fn->
getExprLoc(), diag::warn_arm_interrupt_calling_convention);
7360 if (Caller->hasAttr<AnyX86InterruptAttr>() &&
7361 ((!FDecl || !FDecl->
hasAttr<AnyX86NoCallerSavedRegistersAttr>()))) {
7401 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
7416 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
7424 const auto *Proto = dyn_cast_or_null<FunctionProtoType>(FuncT);
7425 unsigned NumParams = Proto ? Proto->getNumParams() : 0;
7429 assert(UsesADL == ADLCallKind::NotADL &&
7430 "CUDAKernelCallExpr should not use ADL");
7451 TheCall = dyn_cast<CallExpr>(
Result.get());
7452 bool CorrectedTypos = TheCall != TheOldCall;
7453 if (!TheCall)
return Result;
7460 if (CorrectedTypos && Args.size() < NumParams) {
7476 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
7481 if (FDecl && !FDecl->
hasAttr<CUDAGlobalAttr>())
7482 return ExprError(
Diag(LParenLoc,diag::err_kern_call_not_global_function)
7489 return ExprError(
Diag(LParenLoc, diag::err_kern_type_not_void_return)
7493 if (FDecl && FDecl->
hasAttr<CUDAGlobalAttr>())
7494 return ExprError(
Diag(LParenLoc, diag::err_global_call_not_config)
7510 for (
const Expr *Arg : Args) {
7511 if (Arg && Arg->getType()->isWebAssemblyTableType()) {
7513 diag::err_wasm_table_as_function_parameter));
7523 assert(isa<FunctionNoProtoType>(FuncT) &&
"Unknown FunctionType!");
7531 if (!Proto || !(Proto->isVariadic() && Args.size() >= Def->
param_size()))
7532 Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments)
7552 if (!Proto && !Args.empty() &&
7556 Diag(LParenLoc, diag::warn_strict_uses_without_prototype)
7557 << (FDecl !=
nullptr) << FDecl;
7560 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
7561 Expr *Arg = Args[i];
7563 if (Proto && i < Proto->getNumParams()) {
7565 Context, Proto->getParamType(i), Proto->isParamConsumed(i));
7583 diag::err_call_incomplete_argument, Arg))
7591 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
7592 if (!Method->isStatic())
7593 return ExprError(
Diag(LParenLoc, diag::err_member_call_without_object)
7602 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
7603 if (
const auto *RT =
7604 dyn_cast<RecordType>(Args[i]->
getType().getCanonicalType())) {
7605 if (RT->getDecl()->isOrContainsUnion())
7606 Diag(Args[i]->getBeginLoc(), diag::warn_cmse_nonsecure_union)
7614 if (CheckFunctionCall(FDecl, TheCall, Proto))
7617 checkFortifiedBuiltinMemoryFunction(FDecl, TheCall);
7620 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
7622 if (CheckPointerCall(NDecl, TheCall, Proto))
7625 if (CheckOtherCall(TheCall, Proto))
7635 assert(Ty &&
"ActOnCompoundLiteral(): missing type");
7636 assert(InitExpr &&
"ActOnCompoundLiteral(): missing expression");
7654 diag::err_array_incomplete_or_sizeless_type,
7668 std::optional<unsigned> NumInits;
7669 if (
const auto *ILE = dyn_cast<InitListExpr>(LiteralExpr))
7670 NumInits = ILE->getNumInits();
7671 if ((
LangOpts.CPlusPlus || NumInits.value_or(0)) &&
7673 diag::err_variable_object_no_init))
7678 diag::err_typecheck_decl_incomplete_type,
7693 LiteralExpr =
Result.get();
7721 if (
auto ILE = dyn_cast<InitListExpr>(LiteralExpr))
7722 for (
unsigned i = 0, j = ILE->getNumInits(); i != j; i++) {
7723 Expr *Init = ILE->getInit(i);
7728 VK, LiteralExpr, isFileScope);
7740 Diag(LParenLoc, diag::err_compound_literal_with_address_space)
7757 Cleanup.setExprNeedsCleanups(
true);
7776 bool DiagnosedArrayDesignator =
false;
7777 bool DiagnosedNestedDesignator =
false;
7778 bool DiagnosedMixedDesignator =
false;
7782 for (
unsigned I = 0, E = InitArgList.size(); I != E; ++I) {
7783 if (
auto *DIE = dyn_cast<DesignatedInitExpr>(InitArgList[I])) {
7785 FirstDesignator = DIE->getBeginLoc();
7790 if (!DiagnosedNestedDesignator && DIE->size() > 1) {
7791 DiagnosedNestedDesignator =
true;
7792 Diag(DIE->getBeginLoc(), diag::ext_designated_init_nested)
7793 << DIE->getDesignatorsSourceRange();
7796 for (
auto &Desig : DIE->designators()) {
7797 if (!Desig.isFieldDesignator() && !DiagnosedArrayDesignator) {
7798 DiagnosedArrayDesignator =
true;
7799 Diag(Desig.getBeginLoc(), diag::ext_designated_init_array)
7800 << Desig.getSourceRange();
7804 if (!DiagnosedMixedDesignator &&
7805 !isa<DesignatedInitExpr>(InitArgList[0])) {
7806 DiagnosedMixedDesignator =
true;
7807 Diag(DIE->getBeginLoc(), diag::ext_designated_init_mixed)
7808 << DIE->getSourceRange();
7809 Diag(InitArgList[0]->getBeginLoc(), diag::note_designated_init_mixed)
7810 << InitArgList[0]->getSourceRange();
7813 isa<DesignatedInitExpr>(InitArgList[0])) {
7814 DiagnosedMixedDesignator =
true;
7816 Diag(DIE->getBeginLoc(), diag::ext_designated_init_mixed)
7817 << DIE->getSourceRange();
7818 Diag(InitArgList[I]->getBeginLoc(), diag::note_designated_init_mixed)
7819 << InitArgList[I]->getSourceRange();
7823 if (FirstDesignator.
isValid()) {
7827 !DiagnosedNestedDesignator && !DiagnosedMixedDesignator) {
7829 ? diag::warn_cxx17_compat_designated_init
7830 : diag::ext_cxx_designated_init);
7832 Diag(FirstDesignator, diag::ext_designated_init);
7847 for (
unsigned I = 0, E = InitArgList.size(); I != E; ++I) {
7848 if (InitArgList[I]->
getType()->isNonOverloadPlaceholderType()) {
7855 InitArgList[I] = result.
get();
7876 Cleanup.setExprNeedsCleanups(
true);
7883 if (type->isObjCObjectPointerType()) {
7885 }
else if (type->isBlockPointerType()) {
7887 return CK_BlockPointerToObjCPointerCast;
7889 assert(type->isPointerType());
7890 return CK_CPointerToObjCPointerCast;
7907 llvm_unreachable(
"member pointer type in C");
7916 if (SrcAS != DestAS)
7917 return CK_AddressSpaceConversion;
7924 ? CK_BitCast : CK_AnyPointerToBlockPointerCast);
7929 return CK_CPointerToObjCPointerCast;
7931 return CK_BlockPointerToObjCPointerCast;
7933 return CK_PointerToBoolean;
7935 return CK_PointerToIntegral;
7941 llvm_unreachable(
"illegal cast from pointer");
7943 llvm_unreachable(
"Should have returned before this");
7948 return CK_FixedPointCast;
7950 return CK_FixedPointToBoolean;
7952 return CK_FixedPointToIntegral;
7954 return CK_FixedPointToFloating;
7958 diag::err_unimplemented_conversion_with_fixed_point_type)
7960 return CK_IntegralCast;
7965 llvm_unreachable(
"illegal cast to pointer type");
7967 llvm_unreachable(
"Should have returned before this");
7977 return CK_NullToPointer;
7978 return CK_IntegralToPointer;
7980 return CK_IntegralToBoolean;
7982 return CK_IntegralCast;
7984 return CK_IntegralToFloating;
7989 return CK_IntegralRealToComplex;
7993 CK_IntegralToFloating);
7994 return CK_FloatingRealToComplex;
7996 llvm_unreachable(
"member pointer type in C");
7998 return CK_IntegralToFixedPoint;
8000 llvm_unreachable(
"Should have returned before this");
8005 return CK_FloatingCast;
8007 return CK_FloatingToBoolean;
8009 return CK_FloatingToIntegral;
8014 return CK_FloatingRealToComplex;
8018 CK_FloatingToIntegral);
8019 return CK_IntegralRealToComplex;
8023 llvm_unreachable(
"valid float->pointer cast?");
8025 llvm_unreachable(
"member pointer type in C");
8027 return CK_FloatingToFixedPoint;
8029 llvm_unreachable(
"Should have returned before this");
8034 return CK_FloatingComplexCast;
8036 return CK_FloatingComplexToIntegralComplex;
8040 return CK_FloatingComplexToReal;
8042 return CK_FloatingCast;
8045 return CK_FloatingComplexToBoolean;
8049 CK_FloatingComplexToReal);
8050 return CK_FloatingToIntegral;
8054 llvm_unreachable(
"valid complex float->pointer cast?");
8056 llvm_unreachable(
"member pointer type in C");
8059 diag::err_unimplemented_conversion_with_fixed_point_type)
8061 return CK_IntegralCast;
8063 llvm_unreachable(
"Should have returned before this");
8068 return CK_IntegralComplexToFloatingComplex;
8070 return CK_IntegralComplexCast;
8074 return CK_IntegralComplexToReal;
8076 return CK_IntegralCast;
8079 return CK_IntegralComplexToBoolean;
8083 CK_IntegralComplexToReal);
8084 return CK_IntegralToFloating;
8088 llvm_unreachable(
"valid complex int->pointer cast?");
8090 llvm_unreachable(
"member pointer type in C");
8093 diag::err_unimplemented_conversion_with_fixed_point_type)
8095 return CK_IntegralCast;
8097 llvm_unreachable(
"Should have returned before this");
8100 llvm_unreachable(
"Unhandled scalar cast");
8107 len = vecType->getNumElements();
8108 eltType = vecType->getElementType();
8115 if (!type->isRealType())
return false;
8131 auto ValidScalableConversion = [](
QualType FirstType,
QualType SecondType) {
8135 const auto *VecTy = SecondType->getAs<
VectorType>();
8140 return ValidScalableConversion(srcTy, destTy) ||
8141 ValidScalableConversion(destTy, srcTy);
8153 auto ValidScalableConversion = [](
QualType FirstType,
QualType SecondType) {
8157 const auto *VecTy = SecondType->getAs<
VectorType>();
8162 return ValidScalableConversion(srcTy, destTy) ||
8163 ValidScalableConversion(destTy, srcTy);
8175 return matSrcType->
getNumRows() == matDestType->getNumRows() &&
8176 matSrcType->
getNumColumns() == matDestType->getNumColumns();
8182 uint64_t SrcLen, DestLen;
8195 return (SrcLen * SrcEltSize == DestLen * DestEltSize);
8201 "expected at least one type to be a vector here");
8203 bool IsSrcTyAltivec =
8219 return (IsSrcTyAltivec || IsDestTyAltivec);
8255 if (!Vec || !Vec->getElementType()->isIntegralOrEnumerationType())
8260 if (!Vec || !Vec->getElementType()->isIntegralOrEnumerationType())
8277 return Diag(R.
getBegin(), diag::err_invalid_conversion_between_matrixes)
8278 << DestTy << SrcTy << R;
8282 diag::err_invalid_conversion_between_matrix_and_type)
8283 << SrcTy << DestTy << R;
8286 diag::err_invalid_conversion_between_matrix_and_type)
8287 << DestTy << SrcTy << R;
8290 Kind = CK_MatrixCast;
8296 assert(VectorTy->
isVectorType() &&
"Not a vector type!");
8302 diag::err_invalid_conversion_between_vectors :
8303 diag::err_invalid_conversion_between_vector_and_integer)
8304 << VectorTy << Ty << R;
8307 diag::err_invalid_conversion_between_vector_and_scalar)
8308 << VectorTy << Ty << R;
8317 if (DestElemTy == SplattedExpr->
getType())
8318 return SplattedExpr;
8331 CK_BooleanToSignedIntegral);
8332 SplattedExpr = CastExprRes.
get();
8333 CK = CK_IntegralToFloating;
8335 CK = CK_BooleanToSignedIntegral;
8342 SplattedExpr = CastExprRes.
get();
8361 Diag(R.
getBegin(),diag::err_invalid_conversion_between_ext_vectors)
8362 << DestTy << SrcTy << R;
8374 diag::err_invalid_conversion_between_vector_and_scalar)
8375 << DestTy << SrcTy << R;
8377 Kind = CK_VectorSplat;
8386 "ActOnCastExpr(): missing type or expr");
8408 bool isVectorLiteral =
false;
8423 isVectorLiteral =
true;
8426 isVectorLiteral =
true;
8431 if (isVectorLiteral)
8437 if (isa<ParenListExpr>(
CastExpr)) {
8458 assert((isa<ParenListExpr>(E) || isa<ParenExpr>(E)) &&
8459 "Expected paren or paren list expression");
8466 LiteralLParenLoc = PE->getLParenLoc();
8467 LiteralRParenLoc = PE->getRParenLoc();
8468 exprs = PE->getExprs();
8469 numExprs = PE->getNumExprs();
8496 if (numExprs == 1) {
8499 if (Literal.isInvalid())
8505 else if (numExprs < numElems) {
8507 diag::err_incorrect_number_of_vector_initializers);
8511 initExprs.append(exprs, exprs + numExprs);
8521 if (Literal.isInvalid())
8528 initExprs.append(exprs, exprs + numExprs);
8533 initExprs, LiteralRParenLoc);
8568 Expr *NullExpr = LHSExpr;
8569 Expr *NonPointerExpr = RHSExpr;
8576 NonPointerExpr = LHSExpr;
8598 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands_null)
8599 << NonPointerExpr->
getType() << DiagType
8610 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
8618 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_scalar)
8652 bool IsBlockPointer =
false;
8656 IsBlockPointer =
true;
8681 ResultAddrSpace = LAddrSpace;
8683 ResultAddrSpace = RAddrSpace;
8685 S.
Diag(Loc, diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
8692 auto LHSCastKind = CK_BitCast, RHSCastKind = CK_BitCast;
8707 LAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
8709 RAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
8717 lhptee, rhptee,
false,
false,
8720 if (CompositeTy.
isNull()) {
8737 S.
Diag(Loc, diag::ext_typecheck_cond_incompatible_pointers)
8748 QualType ResultTy = [&, ResultAddrSpace]() {
8783 S.
Diag(Loc, diag::err_typecheck_cond_incompatible_operands)
8836 bool IsIntFirstExpr) {
8841 Expr *Expr1 = IsIntFirstExpr ? Int.
get() : PointerExpr;
8842 Expr *Expr2 = IsIntFirstExpr ? PointerExpr : Int.
get();
8844 S.
Diag(Loc, diag::ext_typecheck_cond_pointer_integer_mismatch)
8848 CK_IntegralToPointer);
8882 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
8888 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
8894 if (LHSType == RHSType)
8904 (S, LHS, RHS, LHSType, RHSType,
false);
8938 llvm::raw_svector_ostream OS(Str);
8939 OS <<
"(vector of " << NumElements <<
" '" << EleTyName <<
"' values)";
8940 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
8941 << CondTy << OS.str();
8962 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
8980 S.
Diag(QuestionLoc, diag::err_conditional_vector_size)
8981 << CondTy << VecResTy;
8986 QualType RVE = RV->getElementType();
8989 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
8990 << CondTy << VecResTy;
9005 if (
Cond.isInvalid())
9016 bool IsBoolVecLang =
9040 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
9041 QualType Ty = CE->getCallee()->getType();
9079 "should only occur in error-recovery path.");
9091 if (
Cond.isInvalid())
9114 Diag(QuestionLoc, diag::err_wasm_table_conditional_expression)
9123 diag::err_typecheck_cond_incompatible_operands) << LHSTy << RHSTy
9142 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
9161 if (
const RecordType *LHSRT = LHSTy->
getAs<RecordType>()) {
9162 if (
const RecordType *RHSRT = RHSTy->
getAs<RecordType>())
9163 if (LHSRT->getDecl() == RHSRT->getDecl())
9207 if (!compositeType.
isNull())
9208 return compositeType;
9242 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
9314 if (!(compositeType =
9318 compositeType = RHSOPT->isObjCBuiltinType() ? RHSTy : LHSTy;
9322 RHSOPT->isObjCQualifiedIdType()) &&
9333 Diag(QuestionLoc, diag::ext_typecheck_cond_incompatible_operands)
9344 return compositeType;
9351 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
9371 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
9403 Self.
Diag(Loc,
Note) << ParenRange;
9428 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E)) {
9429 E = MTE->getSubExpr();
9436 *Opcode = OP->getOpcode();
9437 *RHSExprs = OP->getRHS();
9444 if (Call->getNumArgs() != 2)
9450 if (OO < OO_Plus || OO > OO_Arrow ||
9451 OO == OO_PlusPlus || OO == OO_MinusMinus)
9457 *RHSExprs = Call->getArg(1);
9474 return OP->isComparisonOp() || OP->isLogicalOp();
9476 return OP->getOpcode() == UO_LNot;
9506 ? diag::warn_precedence_bitwise_conditional
9507 : diag::warn_precedence_conditional;
9509 Self.
Diag(OpLoc, DiagID)
9515 Self.
PDiag(diag::note_precedence_silence)
9520 Self.
PDiag(diag::note_precedence_conditional_first),
9531 auto GetNullability = [](
QualType Ty) {
9532 std::optional<NullabilityKind> Kind = Ty->getNullability();
9542 auto LHSKind = GetNullability(LHSTy), RHSKind = GetNullability(RHSTy);
9550 MergedKind = RHSKind;
9557 MergedKind = RHSKind;
9559 MergedKind = LHSKind;
9565 if (GetNullability(ResTy) == MergedKind)
9573 auto NewAttr = AttributedType::getNullabilityAttrKind(MergedKind);
9602 CondExpr = CondResult.
get();
9603 LHSExpr = LHSResult.
get();
9604 RHSExpr = RHSResult.
get();
9610 Expr *commonExpr =
nullptr;
9612 commonExpr = CondExpr;
9619 commonExpr = result.
get();
9633 commonExpr = commonRes.
get();
9643 commonExpr = MatExpr.
get();
9651 LHSExpr = CondExpr = opaqueValue;
9659 VK, OK, QuestionLoc);
9660 if (result.
isNull() ||
Cond.isInvalid() || LHS.isInvalid() ||
9667 CheckBoolLikeConversion(
Cond.get(), QuestionLoc);
9675 RHS.get(), result, VK, OK);
9678 commonExpr, opaqueValue,
Cond.get(), LHS.get(), RHS.get(), QuestionLoc,
9679 ColonLoc, result, VK, OK);
9687 if (
const auto *ToFn =
9689 if (
const auto *FromFn =
9708 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
9709 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
9712 const Type *lhptee, *rhptee;
9714 std::tie(lhptee, lhq) =
9716 std::tie(rhptee, rhq) =
9777 diag::warn_typecheck_convert_incompatible_function_pointer_strict,
9800 if (ltrans == rtrans) {
9814 if (isa<PointerType>(lhptee) && isa<PointerType>(rhptee)) {
9816 std::tie(lhptee, lhq) =
9818 std::tie(rhptee, rhq) =
9832 }
while (isa<PointerType>(lhptee) && isa<PointerType>(rhptee));
9834 if (lhptee == rhptee)
9858 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
9859 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
9880 if (LQuals != RQuals)
9909 assert(LHSType.
isCanonical() &&
"LHS was not canonicalized!");
9910 assert(RHSType.
isCanonical() &&
"RHS was not canonicalized!");
9958 return VT->getElementType().getCanonicalType() == ElementType;
9991 if (LHSType == RHSType) {
9998 if (
const auto *AT = dyn_cast<AutoType>(LHSType)) {
9999 if (AT->isGNUAutoType()) {
10007 if (
const AtomicType *AtomicTy = dyn_cast<AtomicType>(LHSType)) {
10012 if (Kind != CK_NoOp && ConvertRHS)
10014 Kind = CK_NonAtomicToAtomic;
10027 Kind = CK_LValueBitCast;
10042 Kind = CK_VectorSplat;
10068 << RHSType << LHSType;
10087 << RHSType << LHSType;
10137 if (
const PointerType *LHSPointer = dyn_cast<PointerType>(LHSType)) {
10139 if (isa<PointerType>(RHSType)) {
10140 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
10142 if (AddrSpaceL != AddrSpaceR)
10143 Kind = CK_AddressSpaceConversion;
10154 Kind = CK_IntegralToPointer;
10160 if (isa<ObjCObjectPointerType>(RHSType)) {
10162 if (LHSPointer->getPointeeType()->isVoidType()) {
10181 if (LHSPointer->getPointeeType()->isVoidType()) {
10182 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
10185 .getAddressSpace();
10187 AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
10196 if (isa<BlockPointerType>(LHSType)) {
10201 .getAddressSpace();
10204 .getAddressSpace();
10205 Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
10211 Kind = CK_IntegralToPointer;
10217 Kind = CK_AnyPointerToBlockPointerCast;
10223 if (RHSPT->getPointeeType()->isVoidType()) {
10224 Kind = CK_AnyPointerToBlockPointerCast;
10232 if (isa<ObjCObjectPointerType>(LHSType)) {
10238 if (
getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
10247 Kind = CK_IntegralToPointer;
10253 if (isa<PointerType>(RHSType)) {
10254 Kind = CK_CPointerToObjCPointerCast;
10276 Kind = CK_BlockPointerToObjCPointerCast;
10288 Kind = CK_NullToPointer;
10293 if (isa<PointerType>(RHSType)) {
10296 Kind = CK_PointerToBoolean;
10302 Kind = CK_PointerToIntegral;
10310 if (isa<ObjCObjectPointerType>(RHSType)) {
10313 Kind = CK_PointerToBoolean;
10319 Kind = CK_PointerToIntegral;
10327 if (isa<TagType>(LHSType) && isa<TagType>(RHSType)) {
10335 Kind = CK_IntToOCLSampler;
10370 if (!UT || !UT->getDecl()->hasAttr<TransparentUnionAttr>())
10377 for (
auto *it : UD->
fields()) {
10378 if (it->getType()->isPointerType()) {
10417 bool DiagnoseCFAudited,
10421 assert((ConvertRHS || !
Diagnose) &&
"can't indicate whether we diagnosed");
10427 ExprResult &RHS = ConvertRHS ? CallerRHS : LocalRHS;
10431 if (RHSPtrType->getPointeeType()->hasAttr(attr::NoDeref) &&
10432 !LHSPtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
10434 diag::warn_noderef_to_dereferenceable_pointer)
10453 AllowedExplicit::None,
10465 if (
getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
10480 RHS.
get(), LHSType,
false, DAP))
10571 if (
getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
10600struct OriginalOperand {
10601 explicit OriginalOperand(
Expr *Op) : Orig(Op), Conversion(nullptr) {
10602 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(Op))
10603 Op = MTE->getSubExpr();
10604 if (
auto *BTE = dyn_cast<CXXBindTemporaryExpr>(Op))
10605 Op = BTE->getSubExpr();
10606 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(Op)) {
10607 Orig = ICE->getSubExprAsWritten();
10608 Conversion = ICE->getConversionFunction();
10621 OriginalOperand OrigLHS(LHS.
get()), OrigRHS(RHS.
get());
10623 Diag(Loc, diag::err_typecheck_invalid_operands)
10624 << OrigLHS.getType() << OrigRHS.getType()
10629 if (OrigLHS.Conversion) {
10630 Diag(OrigLHS.Conversion->getLocation(),
10631 diag::note_typecheck_invalid_operands_converted)
10634 if (OrigRHS.Conversion) {
10636 diag::note_typecheck_invalid_operands_converted)
10654 if (!(LHSNatVec && RHSNatVec)) {
10655 Expr *Vector = LHSNatVec ? LHS.
get() : RHS.
get();
10656 Expr *NonVector = !LHSNatVec ? LHS.
get() : RHS.
get();
10657 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
10659 << Vector->getSourceRange();
10663 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
10686 unsigned &DiagID) {
10695 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
10700 scalarCast = CK_IntegralCast;
10705 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
10708 scalarCast = CK_FloatingCast;
10711 scalarCast = CK_IntegralToFloating;
10720 if (scalarCast != CK_NoOp)
10731 assert(VecTy &&
"Expression E must be a vector");
10736 VecTy->getVectorKind());
10740 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(E))
10741 if (ICE->getSubExpr()->getType() == NewVecTy)
10742 return ICE->getSubExpr();
10744 auto Cast = ElementType->
isIntegerType() ? CK_IntegralCast : CK_FloatingCast;
10767 unsigned NumBits = IntSigned
10769 :
Result.getActiveBits())
10770 :
Result.getActiveBits();
10777 return (IntSigned != OtherIntSigned &&
10783 return (Order < 0);
10807 llvm::APFloat::rmTowardZero);
10810 bool Ignored =
false;
10811 Float.convertToInteger(ConvertBack, llvm::APFloat::rmNearestTiesToEven,
10813 if (
Result != ConvertBack)
10819 unsigned FloatPrec = llvm::APFloat::semanticsPrecision(
10821 if (Bits > FloatPrec)
10834 QualType ScalarTy = Scalar->get()->getType().getUnqualifiedType();
10835 QualType VectorTy = Vector->get()->getType().getUnqualifiedType();
10839 assert(!isa<ExtVectorType>(VT) &&
10840 "ExtVectorTypes should not be handled here!");
10841 VectorEltTy = VT->getElementType();
10846 llvm_unreachable(
"Only Fixed-Length and SVE Vector types are handled here");
10872 ScalarCast = CK_IntegralCast;
10876 ScalarCast = CK_FloatingToIntegral;
10884 llvm::APFloat
Result(0.0);
10890 bool CstScalar = Scalar->get()->isValueDependent() ||
10893 if (!CstScalar && Order < 0)
10899 bool Truncated =
false;
10901 llvm::APFloat::rmNearestTiesToEven, &Truncated);
10906 ScalarCast = CK_FloatingCast;
10911 ScalarCast = CK_IntegralToFloating;
10918 if (ScalarCast != CK_NoOp)
10926 bool AllowBothBool,
10927 bool AllowBoolConversions,
10928 bool AllowBoolOperation,
10929 bool ReportInvalid) {
10930 if (!IsCompAssign) {
10946 assert(LHSVecType || RHSVecType);
10950 if (!AllowBothBool &&
10956 if (!AllowBoolOperation &&
10965 if (LHSVecType && RHSVecType &&
10967 if (isa<ExtVectorType>(LHSVecType)) {
10980 if (AllowBoolConversions && LHSVecType && RHSVecType &&
10990 if (!IsCompAssign &&
10993 RHSVecType->getElementType()->isIntegerType()) {
11002 unsigned &SVEorRVV) {
11019 if (IsSveRVVConversion(LHSType, RHSType, SVEorRVV) ||
11020 IsSveRVVConversion(RHSType, LHSType, SVEorRVV)) {
11021 Diag(Loc, diag::err_typecheck_sve_rvv_ambiguous)
11022 << SVEorRVV << LHSType << RHSType;
11029 unsigned &SVEorRVV) {
11034 if (FirstVecType && SecondVecType) {
11036 if (SecondVecType->getVectorKind() ==
11038 SecondVecType->getVectorKind() ==
11041 if (SecondVecType->getVectorKind() ==
11050 if (SecondVecType &&
11063 if (IsSveRVVGnuConversion(LHSType, RHSType, SVEorRVV) ||
11064 IsSveRVVGnuConversion(RHSType, LHSType, SVEorRVV)) {
11065 Diag(Loc, diag::err_typecheck_sve_rvv_gnu_ambiguous)
11066 << SVEorRVV << LHSType << RHSType;
11072 unsigned DiagID = diag::err_typecheck_vector_not_convertable;
11074 if (isa<ExtVectorType>(LHSVecType)) {
11085 if (isa<ExtVectorType>(RHSVecType)) {
11087 LHSType, RHSVecType->getElementType(),
11100 QualType VecType = LHSVecType ? LHSType : RHSType;
11101 const VectorType *VT = LHSVecType ? LHSVecType : RHSVecType;
11102 QualType OtherType = LHSVecType ? RHSType : LHSType;
11103 ExprResult *OtherExpr = LHSVecType ? &RHS : &LHS;
11108 Diag(Loc, diag::warn_deprecated_lax_vec_conv_all) << RHSType << LHSType;
11112 if (!IsCompAssign) {
11131 if ((!RHSVecType && !RHSType->
isRealType()) ||
11133 Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
11134 << LHSType << RHSType
11144 RHSVecType && isa<ExtVectorType>(RHSVecType) &&
11145 LHSVecType && isa<ExtVectorType>(LHSVecType)) {
11146 Diag(Loc, diag::err_opencl_implicit_vector_conversion) << LHSType
11155 if ((RHSVecType && !isa<ExtVectorType>(RHSVecType)) ||
11156 (LHSVecType && !isa<ExtVectorType>(LHSVecType))) {
11157 QualType Scalar = LHSVecType ? RHSType : LHSType;
11158 QualType Vector = LHSVecType ? LHSType : RHSType;
11159 unsigned ScalarOrVector = LHSVecType && RHSVecType ? 1 : 0;
11161 diag::err_typecheck_vector_not_convertable_implict_truncation)
11162 << ScalarOrVector << Scalar << Vector;
11169 << LHSType << RHSType
11178 if (!IsCompAssign) {
11193 unsigned DiagID = diag::err_typecheck_invalid_operands;
11195 ((LHSBuiltinTy && LHSBuiltinTy->
isSVEBool()) ||
11196 (RHSBuiltinTy && RHSBuiltinTy->isSVEBool()))) {
11217 Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
11226 Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
11235 bool ScalarOrVector =
11238 Diag(Loc, diag::err_typecheck_vector_not_convertable_implict_truncation)
11239 << ScalarOrVector << Scalar << Vector;
11271 S.
Diag(Loc, diag::warn_null_in_arithmetic_operation)
11283 S.
Diag(Loc, diag::warn_null_in_comparison_operation)
11284 << LHSNull << NonNullType
11290 const auto *LUE = dyn_cast<UnaryExprOrTypeTraitExpr>(LHS);
11291 const auto *RUE = dyn_cast<UnaryExprOrTypeTraitExpr>(RHS);
11294 if (LUE->getKind() != UETT_SizeOf || LUE->isArgumentType() ||
11295 RUE->getKind() != UETT_SizeOf)
11302 if (RUE->isArgumentType())
11303 RHSTy = RUE->getArgumentType().getNonReferenceType();
11305 RHSTy = RUE->getArgumentExpr()->IgnoreParens()->getType();
11312 if (
const auto *DRE = dyn_cast<DeclRefExpr>(LHSArg)) {
11313 if (
const ValueDecl *LHSArgDecl = DRE->getDecl())
11314 S.
Diag(LHSArgDecl->getLocation(), diag::note_pointer_declared_here)
11318 QualType ArrayElemTy = ArrayTy->getElementType();
11324 S.
Diag(Loc, diag::warn_division_sizeof_array)
11326 if (
const auto *DRE = dyn_cast<DeclRefExpr>(LHSArg)) {
11327 if (
const ValueDecl *LHSArgDecl = DRE->getDecl())
11328 S.
Diag(LHSArgDecl->getLocation(), diag::note_array_declared_here)
11332 S.
Diag(Loc, diag::note_precedence_silence) << RHS;
11345 S.
PDiag(diag::warn_remainder_division_by_zero)
11351 bool IsCompAssign,
bool IsDiv) {
11429 ? diag::err_typecheck_pointer_arith_void_type
11430 : diag::ext_gnu_void_ptr)
11439 ? diag::err_typecheck_pointer_arith_void_type
11440 : diag::ext_gnu_void_ptr)
11441 << 0 <<
Pointer->getSourceRange();
11452 S.
Diag(Loc, diag::warn_gnu_null_ptr_arith)
11453 <<
Pointer->getSourceRange();
11455 S.
Diag(Loc, diag::warn_pointer_arith_null_ptr)
11472 S.
PDiag(diag::warn_pointer_sub_null_ptr)
11474 <<
Pointer->getSourceRange());
11483 ? diag::err_typecheck_pointer_arith_function_type
11484 : diag::ext_gnu_ptr_func_arith)
11496 assert(
Pointer->getType()->isAnyPointerType());
11498 ? diag::err_typecheck_pointer_arith_function_type
11499 : diag::ext_gnu_ptr_func_arith)
11500 << 0 <<
Pointer->getType()->getPointeeType()
11502 <<
Pointer->getSourceRange();
11510 QualType ResType = Operand->getType();
11512 ResType = ResAtomicType->getValueType();
11518 diag::err_typecheck_arithmetic_incomplete_or_sizeless_type,
11519 Operand->getSourceRange());
11532 QualType ResType = Operand->getType();
11534 ResType = ResAtomicType->getValueType();
11566 if (!isLHSPointer && !isRHSPointer)
return true;
11568 QualType LHSPointeeTy, RHSPointeeTy;
11573 if (isLHSPointer && isRHSPointer) {
11576 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
11584 bool isLHSVoidPtr = isLHSPointer && LHSPointeeTy->
isVoidType();
11585 bool isRHSVoidPtr = isRHSPointer && RHSPointeeTy->
isVoidType();
11586 if (isLHSVoidPtr || isRHSVoidPtr) {
11594 bool isLHSFuncPtr = isLHSPointer && LHSPointeeTy->
isFunctionType();
11595 bool isRHSFuncPtr = isRHSPointer && RHSPointeeTy->
isFunctionType();
11596 if (isLHSFuncPtr || isRHSFuncPtr) {
11618 Expr* IndexExpr = RHSExpr;
11621 IndexExpr = LHSExpr;
11624 bool IsStringPlusInt = StrExpr &&
11630 Self.
Diag(OpLoc, diag::warn_string_plus_int)
11634 if (IndexExpr == RHSExpr) {
11636 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
11641 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
11647 const Expr *StringRefExpr = LHSExpr;
11652 CharExpr = dyn_cast<CharacterLiteral>(LHSExpr->
IgnoreImpCasts());
11653 StringRefExpr = RHSExpr;
11656 if (!CharExpr || !StringRefExpr)
11676 Self.
Diag(OpLoc, diag::warn_string_plus_char)
11677 << DiagRange << Ctx.
CharTy;
11679 Self.
Diag(OpLoc, diag::warn_string_plus_char)
11680 << DiagRange << CharExpr->
getType();
11686 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
11691 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
11700 S.
Diag(Loc, diag::err_typecheck_sub_ptr_compatible)
11719 if (CompLHSTy) *CompLHSTy = compType;
11728 *CompLHSTy = compType;
11737 *CompLHSTy = compType;
11747 if (Opc == BO_Add) {
11754 if (CompLHSTy) *CompLHSTy = compType;
11768 std::swap(PExp, IExp);
11779 if (!IExp->getType()->isIntegerType())
11788 (!IExp->isValueDependent() &&
11789 (!IExp->EvaluateAsInt(KnownVal,
Context) ||
11793 Context, BO_Add, PExp, IExp);
11805 CheckArrayAccess(PExp, IExp);
11814 *CompLHSTy = LHSTy;
11834 if (CompLHSTy) *CompLHSTy = compType;
11843 *CompLHSTy = compType;
11852 *CompLHSTy = compType;
11865 if (CompLHSTy) *CompLHSTy = compType;
11899 CheckArrayAccess(LHS.
get(), RHS.
get(),
nullptr,
11902 if (CompLHSTy) *CompLHSTy = LHS.
get()->
getType();
11946 if (ElementSize.
isZero()) {
11947 Diag(Loc,diag::warn_sub_ptr_zero_size_types)
11953 if (CompLHSTy) *CompLHSTy = LHS.
get()->
getType();
11962 if (
const EnumType *ET = T->getAs<EnumType>())
11963 return ET->getDecl()->isScoped();
11980 llvm::APSInt Right = RHSResult.
Val.
getInt();
11982 if (Right.isNegative()) {
11984 S.
PDiag(diag::warn_shift_negative)
11995 LeftSize = FXSema.getWidth() - (
unsigned)FXSema.hasUnsignedPadding();
11997 llvm::APInt LeftBits(Right.getBitWidth(), LeftSize);
11998 if (Right.uge(LeftBits)) {
12000 S.
PDiag(diag::warn_shift_gt_typewidth)
12020 llvm::APSInt Left = LHSResult.
Val.
getInt();
12031 if (Left.isNegative()) {
12033 S.
PDiag(diag::warn_shift_lhs_negative)
12038 llvm::APInt ResultBits =
12039 static_cast<llvm::APInt &
>(Right) + Left.getSignificantBits();
12040 if (LeftBits.uge(ResultBits))
12042 llvm::APSInt
Result = Left.extend(ResultBits.getLimitedValue());
12048 Result.toString(HexResult, 16,
false,
true);
12054 if (LeftBits == ResultBits - 1) {
12055 S.
Diag(Loc, diag::warn_shift_result_sets_sign_bit)
12056 << HexResult << LHSType
12061 S.
Diag(Loc, diag::warn_shift_result_gt_typewidth)
12062 << HexResult.str() <<
Result.getSignificantBits() << LHSType
12074 S.
Diag(Loc, diag::err_shift_rhs_only_vector)
12080 if (!IsCompAssign) {
12102 S.
Diag(Loc, diag::err_typecheck_invalid_operands)
12109 if (!LHSEleType->isIntegerType()) {
12110 S.
Diag(Loc, diag::err_typecheck_expect_int)
12115 if (!RHSEleType->isIntegerType()) {
12116 S.
Diag(Loc, diag::err_typecheck_expect_int)
12125 if (LHSEleType != RHSEleType) {
12127 LHSEleType = RHSEleType;
12133 }
else if (RHSVecTy) {
12138 S.
Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
12146 if (LHSBT != RHSBT &&
12148 S.
Diag(Loc, diag::warn_typecheck_vector_element_sizes_not_equal)
12165 bool IsCompAssign) {
12166 if (!IsCompAssign) {
12189 if ((LHSBuiltinTy && LHSBuiltinTy->
isSVEBool()) ||
12190 (RHSBuiltinTy && RHSBuiltinTy->
isSVEBool())) {
12191 S.
Diag(Loc, diag::err_typecheck_invalid_operands)
12196 if (!LHSEleType->isIntegerType()) {
12197 S.
Diag(Loc, diag::err_typecheck_expect_int)
12202 if (!RHSEleType->isIntegerType()) {
12203 S.
Diag(Loc, diag::err_typecheck_expect_int)
12211 S.
Diag(Loc, diag::err_typecheck_invalid_operands)
12221 if (LHSEleType != RHSEleType) {
12223 LHSEleType = RHSEleType;
12225 const llvm::ElementCount VecSize =
12234 S.
Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
12240 const llvm::ElementCount VecSize =
12242 if (LHSEleType != RHSEleType) {
12244 RHSEleType = LHSEleType;
12257 bool IsCompAssign) {
12291 if (IsCompAssign) LHS = OldLHS;
12322 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_distinct_pointers
12323 : diag::ext_typecheck_comparison_of_distinct_pointers)
12363 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_fptr_to_void
12364 : diag::ext_typecheck_comparison_of_fptr_to_void)
12371 case Stmt::ObjCArrayLiteralClass:
12372 case Stmt::ObjCDictionaryLiteralClass:
12373 case Stmt::ObjCStringLiteralClass:
12374 case Stmt::ObjCBoxedExprClass:
12417 QualType T = Method->parameters()[0]->getType();
12418 if (!T->isObjCObjectPointerType())
12421 QualType R = Method->getReturnType();
12433 case Stmt::ObjCStringLiteralClass:
12436 case Stmt::ObjCArrayLiteralClass:
12439 case Stmt::ObjCDictionaryLiteralClass:
12442 case Stmt::BlockExprClass:
12444 case Stmt::ObjCBoxedExprClass: {
12446 switch (Inner->getStmtClass()) {
12447 case Stmt::IntegerLiteralClass:
12448 case Stmt::FloatingLiteralClass:
12449 case Stmt::CharacterLiteralClass:
12450 case Stmt::ObjCBoolLiteralExprClass:
12451 case Stmt::CXXBoolLiteralExprClass:
12454 case Stmt::ImplicitCastExprClass: {
12457 if (CK == CK_IntegralToBoolean || CK == CK_IntegralCast)
12476 Literal = LHS.
get();
12479 Literal = RHS.
get();
12484 Other = Other->IgnoreParenCasts();
12495 llvm_unreachable(
"Unknown Objective-C object literal kind");
12499 S.
Diag(Loc, diag::warn_objc_string_literal_comparison)
12500 << Literal->getSourceRange();
12502 S.
Diag(Loc, diag::warn_objc_literal_comparison)
12503 << LiteralKind << Literal->getSourceRange();
12512 S.
Diag(Loc, diag::note_objc_literal_comparison_isequal)
12525 if (!UO || UO->
getOpcode() != UO_LNot)
return;
12535 bool IsBitwiseOp = Opc == BO_And || Opc == BO_Or || Opc == BO_Xor;
12537 << Loc << IsBitwiseOp;
12564 if (
const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(E)) {
12566 }
else if (
const MemberExpr *Mem = dyn_cast<MemberExpr>(E)) {
12567 if (Mem->isImplicitAccess())
12568 D = Mem->getMemberDecl();
12623 S.
Diag(Loc, diag::warn_depr_array_comparison)
12649 Result = AlwaysConstant;
12653 S.
PDiag(diag::warn_comparison_always)
12668 Result = AlwaysConstant;
12672 S.
PDiag(diag::warn_comparison_always)
12678 if (isa<CastExpr>(LHSStripped))
12680 if (isa<CastExpr>(RHSStripped))
12685 Expr *LiteralString =
nullptr;
12686 Expr *LiteralStringStripped =
nullptr;
12687 if ((isa<StringLiteral>(LHSStripped) || isa<ObjCEncodeExpr>(LHSStripped)) &&
12690 LiteralString = LHS;
12691 LiteralStringStripped = LHSStripped;
12692 }
else if ((isa<StringLiteral>(RHSStripped) ||
12693 isa<ObjCEncodeExpr>(RHSStripped)) &&
12696 LiteralString = RHS;
12697 LiteralStringStripped = RHSStripped;
12700 if (LiteralString) {
12702 S.
PDiag(diag::warn_stringcompare)
12703 << isa<ObjCEncodeExpr>(LiteralStringStripped)
12715 llvm_unreachable(
"unhandled cast kind");
12717 case CK_UserDefinedConversion:
12719 case CK_LValueToRValue:
12721 case CK_ArrayToPointerDecay:
12723 case CK_FunctionToPointerDecay:
12725 case CK_IntegralCast:
12727 case CK_FloatingCast:
12729 case CK_IntegralToFloating:
12730 case CK_FloatingToIntegral:
12732 case CK_IntegralComplexCast:
12733 case CK_FloatingComplexCast:
12734 case CK_FloatingComplexToIntegralComplex:
12735 case CK_IntegralComplexToFloatingComplex:
12737 case CK_FloatingComplexToReal:
12738 case CK_FloatingRealToComplex:
12739 case CK_IntegralComplexToReal:
12740 case CK_IntegralRealToComplex:
12753 if (
const auto *ICE = dyn_cast<ImplicitCastExpr>(E))
12780 << 0 << FromType << ToType;
12785 llvm_unreachable(
"unhandled case in switch");
12812 if (NumEnumArgs == 1) {
12814 QualType OtherTy = LHSIsEnum ? RHSStrippedType : LHSStrippedType;
12820 if (NumEnumArgs == 2) {
12829 LHSStrippedType->
castAs<EnumType>()->getDecl()->getIntegerType();
12830 assert(IntType->isArithmeticType());
12840 LHSType = RHSType = IntType;
12852 std::optional<ComparisonCategoryType> CCT =
12864 assert(!
Type.isNull() &&
"composite type for <=> has not been set");
12905 if (
const auto *CL = dyn_cast<CharacterLiteral>(E.
get())) {
12906 if (CL->getValue() == 0)
12910 NullValue ?
"NULL" :
"(void *)0");
12911 }
else if (
const auto *CE = dyn_cast<CStyleCastExpr>(E.
get())) {
12918 NullValue ?
"NULL" :
"(void *)0");
12928 bool IsThreeWay = Opc == BO_Cmp;
12929 bool IsOrdered = IsRelational || IsThreeWay;
12940 if (!IsThreeWay || IsAnyPointerType(LHS) || IsAnyPointerType(RHS)) {
12993 auto computeResultTy = [&]() {
13002 std::optional<ComparisonCategoryType> CCT =
13007 if (CompositeTy->
isPointerType() && LHSIsNull != RHSIsNull) {
13011 Diag(Loc, diag::err_typecheck_three_way_comparison_of_pointer_and_zero)
13012 << (LHSIsNull ? LHS.
get()->getSourceRange()
13021 if (!IsOrdered && LHSIsNull != RHSIsNull) {
13022 bool IsEquality = Opc == BO_EQ;
13034 bool IsError = Opc == BO_Cmp;
13036 IsError ? diag::err_typecheck_ordered_comparison_of_function_pointers
13038 ? diag::warn_typecheck_ordered_comparison_of_function_pointers
13039 : diag::ext_typecheck_ordered_comparison_of_function_pointers;
13068 return computeResultTy();
13084 (IsOrdered ? 2 : 1) &&
13089 return computeResultTy();
13103 if (IsRelational) {
13108 Diag(Loc, diag::ext_typecheck_compare_complete_incomplete_pointers)
13114 }
else if (!IsRelational &&
13118 && !LHSIsNull && !RHSIsNull)
13125 if (LCanPointeeTy != RCanPointeeTy) {
13130 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
13131 << LHSType << RHSType << 0
13137 CastKind Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion
13139 if (LHSIsNull && !RHSIsNull)
13144 return computeResultTy();
13155 if (!IsOrdered && LHSIsNull && RHSIsNull) {
13158 return computeResultTy();
13162 return computeResultTy();
13173 return computeResultTy();
13177 return computeResultTy();
13186 return computeResultTy();
13191 return computeResultTy();
13195 if (IsRelational &&
13204 if (isa<FunctionDecl>(DC))
13206 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
13207 if (CTSD->isInStdNamespace() &&
13208 llvm::StringSwitch<bool>(CTSD->getName())
13209 .Cases(
"less",
"less_equal",
"greater",
"greater_equal",
true)
13215 return computeResultTy();
13228 return computeResultTy();
13238 if (!LHSIsNull && !RHSIsNull &&
13240 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
13245 return computeResultTy();
13252 if (!LHSIsNull && !RHSIsNull) {
13257 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
13261 if (LHSIsNull && !RHSIsNull)
13264 : CK_AnyPointerToBlockPointerCast);
13268 : CK_AnyPointerToBlockPointerCast);
13269 return computeResultTy();
13278 bool RPtrToVoid = RPT ? RPT->getPointeeType()->isVoidType() :
false;
13280 if (!LPtrToVoid && !RPtrToVoid &&
13288 if (LHSIsNull && !RHSIsNull) {
13294 RPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
13303 LPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
13305 return computeResultTy();
13315 if (LHSIsNull && !RHSIsNull)
13319 return computeResultTy();
13325 CK_BlockPointerToObjCPointerCast);
13326 return computeResultTy();
13327 }
else if (!IsOrdered &&
13331 CK_BlockPointerToObjCPointerCast);
13332 return computeResultTy();
13337 unsigned DiagID = 0;
13338 bool isError =
false;
13347 isError ? diag::err_typecheck_ordered_comparison_of_pointer_and_zero
13348 : diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
13351 DiagID = diag::err_typecheck_comparison_of_pointer_integer;
13353 }
else if (IsOrdered)
13354 DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_integer;
13356 DiagID = diag::ext_typecheck_comparison_of_pointer_integer;
13368 LHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
13371 RHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
13372 return computeResultTy();
13376 if (!IsOrdered && RHSIsNull
13379 return computeResultTy();
13381 if (!IsOrdered && LHSIsNull
13384 return computeResultTy();
13387 if (
getLangOpts().getOpenCLCompatibleVersion() >= 200) {
13389 return computeResultTy();
13393 return computeResultTy();
13396 if (LHSIsNull && RHSType->
isQueueT()) {
13398 return computeResultTy();
13401 if (LHSType->
isQueueT() && RHSIsNull) {
13403 return computeResultTy();
13419 if (isa<ExtVectorType>(VTy)) {
13433 "Unhandled vector element size in vector compare");
13453 "Unhandled vector element size in vector compare");
13477 if (Opc == BO_Cmp) {
13478 Diag(Loc, diag::err_three_way_vector_comparison);
13509 Diag(Loc, diag::warn_deprecated_altivec_src_compat);
13539 if (Opc == BO_Cmp) {
13540 Diag(Loc, diag::err_three_way_vector_comparison);
13568 if (LHSBuiltinTy && RHSBuiltinTy && LHSBuiltinTy->
isSVEBool() &&
13569 RHSBuiltinTy->isSVEBool())
13580 if (Loc.isMacroID())
13588 bool Negative =
false;
13589 bool ExplicitPlus =
false;
13590 const auto *LHSInt = dyn_cast<IntegerLiteral>(XorLHS.
get());
13591 const auto *RHSInt = dyn_cast<IntegerLiteral>(XorRHS.
get());
13597 if (
const auto *UO = dyn_cast<UnaryOperator>(XorRHS.
get())) {
13599 if (Opc != UO_Minus && Opc != UO_Plus)
13601 RHSInt = dyn_cast<IntegerLiteral>(UO->getSubExpr());
13604 Negative = (Opc == UO_Minus);
13605 ExplicitPlus = !Negative;
13611 const llvm::APInt &LeftSideValue = LHSInt->getValue();
13612 llvm::APInt RightSideValue = RHSInt->getValue();
13613 if (LeftSideValue != 2 && LeftSideValue != 10)
13616 if (LeftSideValue.getBitWidth() != RightSideValue.getBitWidth())
13621 llvm::StringRef ExprStr =
13626 llvm::StringRef XorStr =
13629 if (XorStr ==
"xor")
13640 RightSideValue = -RightSideValue;
13641 RHSStr =
"-" + RHSStr;
13642 }
else if (ExplicitPlus) {
13643 RHSStr =
"+" + RHSStr;
13646 StringRef LHSStrRef = LHSStr;
13647 StringRef RHSStrRef = RHSStr;
13650 if (LHSStrRef.startswith(
"0b") || LHSStrRef.startswith(
"0B") ||
13651 RHSStrRef.startswith(
"0b") || RHSStrRef.startswith(
"0B") ||
13652 LHSStrRef.startswith(
"0x") || LHSStrRef.startswith(
"0X") ||
13653 RHSStrRef.startswith(
"0x") || RHSStrRef.startswith(
"0X") ||
13654 (LHSStrRef.size() > 1 && LHSStrRef.startswith(
"0")) ||
13655 (RHSStrRef.size() > 1 && RHSStrRef.startswith(
"0")) ||
13656 LHSStrRef.contains(
'\'') || RHSStrRef.contains(
'\''))
13661 const llvm::APInt XorValue = LeftSideValue ^ RightSideValue;
13662 int64_t RightSideIntValue = RightSideValue.getSExtValue();
13663 if (LeftSideValue == 2 && RightSideIntValue >= 0) {
13664 std::string SuggestedExpr =
"1 << " + RHSStr;
13665 bool Overflow =
false;
13666 llvm::APInt One = (LeftSideValue - 1);
13667 llvm::APInt PowValue = One.sshl_ov(RightSideValue, Overflow);
13669 if (RightSideIntValue < 64)
13670 S.
Diag(Loc, diag::warn_xor_used_as_pow_base)
13671 << ExprStr <<
toString(XorValue, 10,
true) << (
"1LL << " + RHSStr)
13673 else if (RightSideIntValue == 64)
13674 S.
Diag(Loc, diag::warn_xor_used_as_pow)
13675 << ExprStr <<
toString(XorValue, 10,
true);
13679 S.
Diag(Loc, diag::warn_xor_used_as_pow_base_extra)
13680 << ExprStr <<
toString(XorValue, 10,
true) << SuggestedExpr
13683 ExprRange, (RightSideIntValue == 0) ?
"1" : SuggestedExpr);
13686 S.
Diag(Loc, diag::note_xor_used_as_pow_silence)
13687 << (
"0x2 ^ " + RHSStr) << SuggestXor;
13688 }
else if (LeftSideValue == 10) {
13689 std::string SuggestedValue =
"1e" + std::to_string(RightSideIntValue);
13690 S.
Diag(Loc, diag::warn_xor_used_as_pow_base)
13691 << ExprStr <<
toString(XorValue, 10,
true) << SuggestedValue
13693 S.
Diag(Loc, diag::note_xor_used_as_pow_silence)
13694 << (
"0xA ^ " + RHSStr) << SuggestXor;
13710 getLangOpts().getOpenCLCompatibleVersion() < 120 &&
13725 bool IsCompAssign) {
13726 if (!IsCompAssign) {
13742 assert((LHSMatType || RHSMatType) &&
"At least one operand must be a matrix");
13751 if (LHSMatType && !RHSMatType) {
13759 if (!LHSMatType && RHSMatType) {
13771 bool IsCompAssign) {
13772 if (!IsCompAssign) {
13783 assert((LHSMatType || RHSMatType) &&
"At least one operand must be a matrix");
13785 if (LHSMatType && RHSMatType) {
13786 if (LHSMatType->getNumColumns() != RHSMatType->
getNumRows())
13794 QualType LHSELTy = LHSMatType->getElementType(),
13825 bool IsCompAssign =
13826 Opc == BO_AndAssign || Opc == BO_OrAssign || Opc == BO_XorAssign;
13837 LegalBoolVecOperator,
13867 ExprResult LHSResult = LHS, RHSResult = RHS;
13870 if (LHSResult.
isInvalid() || RHSResult.isInvalid())
13872 LHS = LHSResult.
get();
13873 RHS = RHSResult.
get();
13892 bool EnumConstantInBoolContext =
false;
13894 if (
const auto *DREHS = dyn_cast<DeclRefExpr>(HS.get())) {
13895 const auto *ECDHS = dyn_cast<EnumConstantDecl>(DREHS->getDecl());
13896 if (ECDHS && ECDHS->getInitVal() != 0 && ECDHS->getInitVal() != 1)
13897 EnumConstantInBoolContext =
true;
13901 if (EnumConstantInBoolContext)
13902 Diag(Loc, diag::warn_enum_constant_in_bool_context);
13907 const auto *LHSATy = dyn_cast<ArrayType>(LHSTy);
13908 const auto *RHSATy = dyn_cast<ArrayType>(RHSTy);
13909 if ((LHSATy && LHSATy->getElementType().isWebAssemblyReferenceType()) ||
13910 (RHSATy && RHSATy->getElementType().isWebAssemblyReferenceType())) {
13932 Diag(Loc, diag::warn_logical_instead_of_bitwise)
13935 Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
13936 << (Opc == BO_LAnd ?
"&" :
"|")
13939 Opc == BO_LAnd ?
"&" :
"|");
13940 if (Opc == BO_LAnd)
13942 Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
13998 const MemberExpr *ME = dyn_cast<MemberExpr>(E);
13999 if (!ME)
return false;
14003 if (!
Base)
return false;
14004 return Base->getMethodDecl() !=
nullptr;
14024 assert(var->
hasLocalStorage() &&
"capture added 'const' to non-local?");
14032 if (
auto *FD = dyn_cast<FunctionDecl>(DC))
14075 bool DiagnosticEmitted =
false;
14079 bool IsDereference =
false;
14080 bool NextIsDereference =
false;
14084 IsDereference = NextIsDereference;
14087 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
14088 NextIsDereference = ME->isArrow();
14089 const ValueDecl *VD = ME->getMemberDecl();
14090 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(VD)) {
14092 if (Field->isMutable()) {
14093 assert(DiagnosticEmitted &&
"Expected diagnostic not emitted.");
14098 if (!DiagnosticEmitted) {
14099 S.
Diag(Loc, diag::err_typecheck_assign_const)
14101 << Field->getType();
14102 DiagnosticEmitted =
true;
14105 <<
ConstMember <<
false << Field << Field->getType()
14106 << Field->getSourceRange();
14110 }
else if (
const VarDecl *VDecl = dyn_cast<VarDecl>(VD)) {
14111 if (VDecl->getType().isConstQualified()) {
14112 if (!DiagnosticEmitted) {
14113 S.
Diag(Loc, diag::err_typecheck_assign_const)
14115 << VDecl->getType();
14116 DiagnosticEmitted =
true;
14119 <<
ConstMember <<
true << VDecl << VDecl->getType()
14120 << VDecl->getSourceRange();
14127 dyn_cast<ArraySubscriptExpr>(E)) {
14131 dyn_cast<ExtVectorElementExpr>(E)) {
14138 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
14142 if (!DiagnosticEmitted) {
14143 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
14145 DiagnosticEmitted =
true;
14148 diag::note_typecheck_assign_const)
14152 }
else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
14154 if (
const ValueDecl *VD = DRE->getDecl()) {
14156 if (!DiagnosticEmitted) {
14157 S.
Diag(Loc, diag::err_typecheck_assign_const)
14159 DiagnosticEmitted =
true;
14161 S.
Diag(VD->getLocation(), diag::note_typecheck_assign_const)
14162 <<
ConstVariable << VD << VD->getType() << VD->getSourceRange();
14165 }
else if (isa<CXXThisExpr>(E)) {
14167 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(DC)) {
14168 if (MD->isConst()) {
14169 if (!DiagnosticEmitted) {
14170 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
14172 DiagnosticEmitted =
true;
14174 S.
Diag(MD->getLocation(), diag::note_typecheck_assign_const)
14181 if (DiagnosticEmitted)
14185 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange <<
ConstUnknown;
14195 const RecordType *Ty,
14198 bool &DiagnosticEmitted) {
14199 std::vector<const RecordType *> RecordTypeList;
14200 RecordTypeList.push_back(Ty);
14201 unsigned NextToCheckIndex = 0;
14204 while (RecordTypeList.size() > NextToCheckIndex) {
14205 bool IsNested = NextToCheckIndex > 0;
14207 RecordTypeList[NextToCheckIndex]->getDecl()->fields()) {
14209 QualType FieldTy = Field->getType();
14211 if (!DiagnosticEmitted) {
14212 S.
Diag(Loc, diag::err_typecheck_assign_const)
14214 << IsNested << Field;
14215 DiagnosticEmitted =
true;
14217 S.
Diag(Field->getLocation(), diag::note_typecheck_assign_const)
14219 << FieldTy << Field->getSourceRange();
14224 if (
const auto *FieldRecTy = FieldTy->
getAs<RecordType>()) {
14225 if (!llvm::is_contained(RecordTypeList, FieldRecTy))
14226 RecordTypeList.push_back(FieldRecTy);
14229 ++NextToCheckIndex;
14238 assert(Ty->
isRecordType() &&
"lvalue was not record?");
14241 bool DiagEmitted =
false;
14243 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E))
14246 else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
14271 unsigned DiagID = 0;
14272 bool NeedType =
false;
14279 DiagID = diag::err_block_decl_ref_not_modifiable_lvalue;
14281 DiagID = diag::err_lambda_decl_ref_not_modifiable_lvalue;
14289 if (declRef && isa<VarDecl>(declRef->
getDecl())) {
14302 ? diag::err_typecheck_arc_assign_self_class_method
14303 : diag::err_typecheck_arc_assign_self;
14306 }
else if (var->
hasAttr<ObjCExternallyRetainedAttr>() ||
14307 isa<ParmVarDecl>(var)) {
14308 DiagID = diag::err_typecheck_arc_assign_externally_retained;
14312 DiagID = diag::err_typecheck_arr_assign_enumeration;
14316 if (Loc != OrigLoc)
14342 DiagID = diag::err_typecheck_array_not_modifiable_lvalue;
14346 DiagID = diag::err_typecheck_non_object_not_modifiable_lvalue;
14350 DiagID = diag::err_typecheck_lvalue_casts_not_supported;
14353 llvm_unreachable(
"did not take early return for MLV_Valid");
14357 DiagID = diag::err_typecheck_expression_not_modifiable_lvalue;
14362 diag::err_typecheck_incomplete_type_not_modifiable_lvalue, E);
14364 DiagID = diag::err_typecheck_duplicate_vector_components_not_mlvalue;
14367 llvm_unreachable(
"readonly properties should be processed differently");
14369 DiagID = diag::err_readonly_message_assignment;
14372 DiagID = diag::err_no_subobject_property_setting;
14377 if (Loc != OrigLoc)
14393 if (Loc.isInvalid() || Loc.isMacroID())
14399 MemberExpr *ML = dyn_cast<MemberExpr>(LHSExpr);
14400 MemberExpr *MR = dyn_cast<MemberExpr>(RHSExpr);
14402 if (!(isa<CXXThisExpr>(ML->
getBase()) && isa<CXXThisExpr>(MR->
getBase())))
14408 if (LHSDecl != RHSDecl)
14413 if (RefTy->getPointeeType().isVolatileQualified())
14416 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 0;
14426 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 1;
14450 Diag(Loc, diag::err_opencl_half_load_store) << 1
14457 Diag(Loc, diag::err_wasm_table_art) << 0;
14462 if (CompoundType.
isNull()) {
14481 Diag(Loc, diag::err_objc_object_assignment)
14488 RHSCheck = ICE->getSubExpr();
14489 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(RHSCheck)) {
14490 if ((UO->getOpcode() == UO_Plus || UO->getOpcode() == UO_Minus) &&
14491 Loc.isFileID() && UO->getOperatorLoc().isFileID() &&
14493 Loc.getLocWithOffset(1) == UO->getOperatorLoc() &&
14496 Loc.getLocWithOffset(2) != UO->getSubExpr()->getBeginLoc() &&
14497 UO->getSubExpr()->getBeginLoc().isFileID()) {
14498 Diag(Loc, diag::warn_not_compound_assign)
14499 << (UO->getOpcode() == UO_Plus ?
"+" :
"-")
14500 <<
SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc());
14510 const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(InnerLHS);
14546 if (CompoundType.
isNull()) {
14572 if (
const CastExpr *CE = dyn_cast<CastExpr>(E)) {
14573 if (CE->getCastKind() == CK_ToVoid) {
14579 CE->getSubExpr()->getType()->isDependentType()) {
14584 if (
const auto *CE = dyn_cast<CallExpr>(E))
14585 return CE->getCallReturnType(Context)->isVoidType();
14594 if (Loc.isMacroID())
14608 const unsigned ForIncrementFlags =
14614 if ((ScopeFlags & ForIncrementFlags) == ForIncrementFlags ||
14615 (ScopeFlags & ForInitFlags) == ForInitFlags)
14620 while (
const BinaryOperator *BO = dyn_cast<BinaryOperator>(LHS)) {
14621 if (BO->getOpcode() != BO_Comma)
14623 LHS = BO->getRHS();
14630 Diag(Loc, diag::warn_comma_operator);
14634 LangOpts.CPlusPlus ?
"static_cast<void>("
14666 diag::err_incomplete_type);
14681 bool IsInc,
bool IsPrefix) {
14690 ResType = ResAtomicType->getValueType();
14692 assert(!ResType.
isNull() &&
"no type for increment/decrement expression");
14702 : diag::warn_increment_bool)
14706 S.
Diag(OpLoc, diag::err_increment_decrement_enum) << IsInc << ResType;
14722 S.
Diag(OpLoc, diag::ext_integer_increment_complex)
14739 S.
Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
14750 S.
Diag(OpLoc, diag::warn_deprecated_increment_decrement_volatile)
14751 << IsInc << ResType;
14784 case Stmt::DeclRefExprClass:
14786 case Stmt::MemberExprClass:
14790 if (cast<MemberExpr>(E)->isArrow())
14794 case Stmt::ArraySubscriptExprClass: {
14799 if (ICE->getSubExpr()->getType()->isArrayType())
14804 case Stmt::UnaryOperatorClass: {
14816 case Stmt::ParenExprClass:
14818 case Stmt::ImplicitCastExprClass:
14822 case Stmt::CXXUuidofExprClass:
14832 AO_Vector_Element = 1,
14833 AO_Property_Expansion = 2,
14834 AO_Register_Variable = 3,
14835 AO_Matrix_Element = 4,
14856 if (PTy->getKind() == BuiltinType::Overload) {
14858 if (!isa<OverloadExpr>(E)) {
14859 assert(cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf);
14860 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof_addrof_function)
14866 if (isa<UnresolvedMemberExpr>(Ovl))
14868 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
14876 if (PTy->getKind() == BuiltinType::UnknownAny)
14879 if (PTy->getKind() == BuiltinType::BoundMember) {
14880 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
14903 auto* VarRef = dyn_cast<DeclRefExpr>(op);
14904 if (VarRef && VarRef->refersToEnclosingVariableOrCapture()) {
14905 Diag(op->
getExprLoc(), diag::err_opencl_taking_address_capture);
14913 if (uOp->getOpcode() == UO_Deref)
14916 return uOp->getSubExpr()->getType();
14923 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(dcl))
14929 unsigned AddressOfError = AO_No_Error;
14934 : diag::ext_typecheck_addrof_temporary)
14941 }
else if (isa<ObjCSelectorExpr>(op)) {
14948 if (!isa<DeclRefExpr>(op)) {
14949 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
14957 if (OrigOp.
get() != DRE) {
14958 Diag(OpLoc, diag::err_parens_pointer_member_function)
14964 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
14969 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
14976 if (isa<CXXDestructorDecl>(MD))
14990 if (isa<PseudoObjectExpr>(op)) {
14991 AddressOfError = AO_Property_Expansion;
14993 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof)
15000 AddressOfError = AO_Bit_Field;
15003 AddressOfError = AO_Vector_Element;
15006 AddressOfError = AO_Matrix_Element;
15010 if (
const VarDecl *vd = dyn_cast<VarDecl>(dcl)) {
15015 AddressOfError = AO_Register_Variable;
15017 }
else if (isa<MSPropertyDecl>(dcl)) {
15018 AddressOfError = AO_Property_Expansion;
15019 }
else if (isa<FunctionTemplateDecl>(dcl)) {
15021 }
else if (isa<FieldDecl>(dcl) || isa<IndirectFieldDecl>(dcl)) {
15025 if (isa<DeclRefExpr>(op) && cast<DeclRefExpr>(op)->getQualifier()) {
15030 diag::err_cannot_form_pointer_to_member_of_reference_type)
15035 while (cast<RecordDecl>(Ctx)->isAnonymousStructOrUnion())
15049 llvm_unreachable(
"Unknown/unexpected decl type");
15052 if (AddressOfError != AO_No_Error) {
15072 Diag(OpLoc, diag::err_wasm_ca_reference)
15077 Diag(OpLoc, diag::err_wasm_table_pr)
15083 CheckAddressOfPackedMember(op);
15089 const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Exp);
15095 const ParmVarDecl *Param = dyn_cast<ParmVarDecl>(D);
15098 if (
const FunctionDecl* FD = dyn_cast<FunctionDecl>(Param->getDeclContext()))
15099 if (!FD->hasAttr<NonNullAttr>() && !Param->hasAttr<NonNullAttr>())
15102 FD->ModifiedNonNullParams.insert(Param);
15108 bool IsAfterAmp =
false) {
15115 Op = ConvResult.
get();
15119 if (isa<CXXReinterpretCastExpr>(Op)) {
15127 Result = PT->getPointeeType();
15135 if (PR.
get() != Op)
15140 S.
Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer)
15145 if (
Result->isVoidType()) {
15151 S.
Diag(OpLoc, diag::err_typecheck_indirection_through_void_pointer_cpp)
15154 S.
Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
15171 default: llvm_unreachable(
"Unknown binop!");
15172 case tok::periodstar: Opc = BO_PtrMemD;
break;
15173 case tok::arrowstar: Opc = BO_PtrMemI;
break;
15174 case tok::star: Opc = BO_Mul;
break;
15175 case tok::slash: Opc = BO_Div;
break;
15176 case tok::percent: Opc = BO_Rem;
break;
15177 case tok::plus: Opc = BO_Add;
break;
15178 case tok::minus: Opc = BO_Sub;
break;
15179 case tok::lessless: Opc = BO_Shl;
break;
15180 case tok::greatergreater: Opc = BO_Shr;
break;
15181 case tok::lessequal: Opc = BO_LE;
break;
15182 case tok::less: Opc = BO_LT;
break;
15183 case tok::greaterequal: Opc = BO_GE;
break;
15184 case tok::greater: Opc = BO_GT;
break;
15185 case tok::exclaimequal: Opc = BO_NE;
break;
15186 case tok::equalequal: Opc = BO_EQ;
break;
15187 case tok::spaceship: Opc = BO_Cmp;
break;
15188 case tok::amp: Opc = BO_And;
break;
15189 case tok::caret: Opc = BO_Xor;
break;
15190 case tok::pipe: Opc = BO_Or;
break;
15191 case tok::ampamp: Opc = BO_LAnd;
break;
15192 case tok::pipepipe: Opc = BO_LOr;
break;
15193 case tok::equal: Opc = BO_Assign;
break;
15194 case tok::starequal: Opc = BO_MulAssign;
break;
15195 case tok::slashequal: Opc = BO_DivAssign;
break;
15196 case tok::percentequal: Opc = BO_RemAssign;
break;
15197 case tok::plusequal: Opc = BO_AddAssign;
break;
15198 case tok::minusequal: Opc = BO_SubAssign;
break;
15199 case tok::lesslessequal: Opc = BO_ShlAssign;
break;
15200 case tok::greatergreaterequal: Opc = BO_ShrAssign;
break;
15201 case tok::ampequal: Opc = BO_AndAssign;
break;
15202 case tok::caretequal: Opc = BO_XorAssign;
break;
15203 case tok::pipeequal: Opc = BO_OrAssign;
break;
15204 case tok::comma: Opc = BO_Comma;
break;
15213 default: llvm_unreachable(
"Unknown unary op!");
15214 case tok::plusplus: Opc = UO_PreInc;
break;
15215 case tok::minusminus: Opc = UO_PreDec;
break;
15216 case tok::amp: Opc = UO_AddrOf;
break;
15217 case tok::star: Opc = UO_Deref;
break;
15218 case tok::plus: Opc = UO_Plus;
break;
15219 case tok::minus: Opc = UO_Minus;
break;
15220 case tok::tilde: Opc = UO_Not;
break;
15221 case tok::exclaim: Opc = UO_LNot;
break;
15222 case tok::kw___real: Opc = UO_Real;
break;
15223 case tok::kw___imag: Opc = UO_Imag;
break;
15224 case tok::kw___extension__: Opc = UO_Extension;
break;
15240 if (!isa<ParmVarDecl>(SelfAssigned))
15242 const auto *Method =
15256 llvm::find_if(
Parent->fields(),
15258 return F->getDeclName() == Name;
15260 return (Field !=
Parent->field_end()) ? *Field :
nullptr;
15275 const DeclRefExpr *LHSDeclRef = dyn_cast<DeclRefExpr>(LHSExpr);
15276 const DeclRefExpr *RHSDeclRef = dyn_cast<DeclRefExpr>(RHSExpr);
15277 if (!LHSDeclRef || !RHSDeclRef ||
15285 if (LHSDecl != RHSDecl)
15290 if (RefTy->getPointeeType().isVolatileQualified())
15293 auto Diag = S.
Diag(OpLoc, IsBuiltin ? diag::warn_self_assignment_builtin
15294 : diag::warn_self_assignment_overloaded)
15299 Diag << 1 << SelfAssignField
15312 const Expr *ObjCPointerExpr =
nullptr, *OtherExpr =
nullptr;
15317 ObjCPointerExpr = LHS;
15321 ObjCPointerExpr = RHS;
15329 if (ObjCPointerExpr && isa<IntegerLiteral>(OtherExpr->IgnoreParenCasts())) {
15330 unsigned Diag = diag::warn_objc_pointer_masking;
15338 StringRef SelArg0 = S.getNameForSlot(0);
15339 if (SelArg0.startswith(
"performSelector"))
15340 Diag = diag::warn_objc_pointer_masking_performSelector;
15351 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
15352 return DRE->getDecl();
15353 if (
auto *ME = dyn_cast<MemberExpr>(E))
15354 return ME->getMemberDecl();
15355 if (
auto *IRE = dyn_cast<ObjCIvarRefExpr>(E))
15356 return IRE->getDecl();
15371 "Result must be a vector of half or short");
15374 "both operands expected to be a half vector");
15386 ResultTy, VK, OK, OpLoc, FPFeatures,
15387 BinOpResTy, BinOpResTy);
15391 BinOpResTy, VK, OK, OpLoc, FPFeatures);
15395static std::pair<ExprResult, ExprResult>
15405 RHS,
nullptr,
false,
15406 [Opc, LHS](
Expr *E) {
15407 if (Opc != BO_Assign)
15414 return std::make_pair(LHS, RHS);
15421 if (!OpRequiresConversion || Ctx.
getLangOpts().NativeHalfType ||
15425 auto HasVectorOfHalfType = [&Ctx](
Expr *E) {
15435 return VT->getElementType().getCanonicalType() == Ctx.
HalfTy;
15440 return HasVectorOfHalfType(E0) && (!E1 || HasVectorOfHalfType(E1));
15462 if (Init.isInvalid())
15464 RHSExpr = Init.get();
15474 bool ConvertHalfVec =
false;
15477 if (!LHS.
isUsable() || !RHS.isUsable())
15487 if (BO_Assign == Opc)
15488 Diag(OpLoc, diag::err_opencl_atomic_init) << 0 << SR;
15516 if (!ResultTy.
isNull()) {
15533 if (
auto *BE = dyn_cast<BlockExpr>(RHS.get()->IgnoreParens()))
15535 if (
auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
15536 if (VD->hasLocalStorage() &&
getCurScope()->isDeclScope(VD))
15537 BE->getBlockDecl()->setCanAvoidCopyToHeap();
15548 Opc == BO_PtrMemI);
15552 ConvertHalfVec =
true;
15560 ConvertHalfVec =
true;
15564 ConvertHalfVec =
true;
15575 ConvertHalfVec =
true;
15580 ConvertHalfVec =
true;
15584 ConvertHalfVec =
true;
15597 ConvertHalfVec =
true;
15602 ConvertHalfVec =
true;
15604 Opc == BO_DivAssign);
15605 CompLHSTy = CompResultTy;
15612 CompLHSTy = CompResultTy;
15618 ConvertHalfVec =
true;
15625 ConvertHalfVec =
true;
15634 CompLHSTy = CompResultTy;
15645 CompLHSTy = CompResultTy;
15653 VK = RHS.get()->getValueKind();
15654 OK = RHS.get()->getObjectKind();
15668 "both sides are half vectors or neither sides are");
15673 CheckArrayAccess(LHS.
get());
15674 CheckArrayAccess(RHS.get());
15680 if (ObjectSetClass && isa<ObjCIsaExpr>(LHS.
get())) {
15684 "object_setClass(")
15697 if (CompResultTy.
isNull()) {
15698 if (ConvertHalfVec)
15718 if (ConvertHalfVec)
15723 Context, LHS.
get(), RHS.get(), Opc, ResultTy, VK, OK, OpLoc,
15740 if (isLeftComp == isRightComp)
15745 bool isLeftBitwise = LHSBO && LHSBO->
isBitwiseOp();
15746 bool isRightBitwise = RHSBO && RHSBO->
isBitwiseOp();
15747 if (isLeftBitwise || isRightBitwise)
15759 Self.
Diag(OpLoc, diag::warn_precedence_bitwise_rel)
15762 Self.
PDiag(diag::note_precedence_silence) << OpStr,
15763 (isLeftComp ? LHSExpr : RHSExpr)->getSourceRange());
15765 Self.
PDiag(diag::note_precedence_bitwise_first)
15780 Self.
PDiag(diag::note_precedence_silence)
15789 if (Bop->getOpcode() == BO_LAnd) {
15792 if (!isa<StringLiteral>(Bop->getLHS()->IgnoreParenImpCasts()))
15794 }
else if (Bop->getOpcode() == BO_LOr) {
15795 if (
BinaryOperator *RBop = dyn_cast<BinaryOperator>(Bop->getRHS())) {
15798 if (RBop->getOpcode() == BO_LAnd &&
15799 isa<StringLiteral>(RBop->getRHS()->IgnoreParenImpCasts()))
15810 if (Bop->getOpcode() == BO_LAnd) {
15813 if (!isa<StringLiteral>(Bop->getRHS()->IgnoreParenImpCasts()))
15825 if (Bop->isBitwiseOp() && Bop->getOpcode() < Opc) {
15826 S.
Diag(Bop->getOperatorLoc(), diag::warn_bitwise_op_in_bitwise_op)
15828 << Bop->getSourceRange() << OpLoc;
15830 S.
PDiag(diag::note_precedence_silence)
15831 << Bop->getOpcodeStr(),
15832 Bop->getSourceRange());
15838 Expr *SubExpr, StringRef Shift) {
15840 if (Bop->getOpcode() == BO_Add || Bop->getOpcode() == BO_Sub) {
15841 StringRef Op = Bop->getOpcodeStr();
15842 S.
Diag(Bop->getOperatorLoc(), diag::warn_addition_in_bitshift)
15843 << Bop->getSourceRange() << OpLoc << Shift << Op;
15845 S.
PDiag(diag::note_precedence_silence) << Op,
15846 Bop->getSourceRange());
15862 if (Kind != OO_LessLess && Kind != OO_GreaterGreater)
15865 S.
Diag(OpLoc, diag::warn_overloaded_shift_in_comparison)
15867 << (Kind == OO_LessLess);
15869 S.
PDiag(diag::note_precedence_silence)
15870 << (Kind == OO_LessLess ?
"<<" :
">>"),
15873 S, OpLoc, S.
PDiag(diag::note_evaluate_comparison_first),
15887 if ((Opc == BO_Or || Opc == BO_Xor) &&
15895 if (Opc == BO_LOr && !OpLoc.
isMacroID()) {
15901 || Opc == BO_Shr) {
15918 assert(LHSExpr &&
"ActOnBinOp(): missing left expression");
15919 assert(RHSExpr &&
"ActOnBinOp(): missing right expression");
15924 return BuildBinOp(S, TokLoc, Opc, LHSExpr, RHSExpr);
15930 if (OverOp !=
OO_None && OverOp != OO_Equal)
15984 LHSExpr = LHS.
get();
15985 RHSExpr = RHS.
get();
15996 if (pty->getKind() == BuiltinType::PseudoObject &&
16009 RHSExpr = resolvedRHS.
get();
16023 (pty->getKind() == BuiltinType::BoundMember ||
16024 pty->getKind() == BuiltinType::Overload)) {
16025 auto *OE = dyn_cast<OverloadExpr>(LHSExpr);
16026 if (OE && !OE->hasTemplateKeyword() && !OE->hasExplicitTemplateArgs() &&
16027 llvm::any_of(OE->decls(), [](
NamedDecl *ND) {
16028 return isa<FunctionTemplateDecl>(ND);
16030 Diag(OE->getQualifier() ? OE->getQualifierLoc().getBeginLoc()
16031 : OE->getNameLoc(),
16032 diag::err_template_kw_missing)
16033 << OE->getName().getAsString() <<
"";
16040 LHSExpr = LHS.
get();
16047 if (Opc == BO_Assign && pty->getKind() == BuiltinType::Overload) {
16063 RHSExpr = resolvedRHS.
get();
16083 "Should only occur in error-recovery path.");
16089 Context, LHSExpr, RHSExpr, Opc,
16109 ResultType = RHSExpr->
getType();
16125 if (T.isNull() || T->isDependentType())
16141 bool CanOverflow =
false;
16143 bool ConvertHalfVec =
false;
16152 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16159 if (Opc == UO_AddrOf)
16160 return ExprError(
Diag(OpLoc, diag::err_hlsl_operator_unsupported) << 0);
16161 if (Opc == UO_Deref)
16162 return ExprError(
Diag(OpLoc, diag::err_hlsl_operator_unsupported) << 1);
16172 Opc == UO_PreInc ||
16174 Opc == UO_PreInc ||
16180 CheckAddressOfNoDeref(InputExpr);
16192 CanOverflow = Opc == UO_Minus &&
16203 if (ConvertHalfVec)
16223 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16236 Diag(OpLoc, diag::ext_integer_complement_complex)
16244 if (!T->isIntegerType())
16245 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16248 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16268 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16286 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16295 if (!T->isIntegerType())
16296 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16305 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16312 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16344 "the co_await expression must be non-dependant before "
16345 "building operator co_await");
16355 if (Opc != UO_AddrOf && Opc != UO_Deref)
16356 CheckArrayAccess(Input.
get());
16362 if (Opc == UO_Deref && UO->getType()->hasAttr(attr::NoDeref) &&
16363 !isa<ArrayType>(UO->getType().getDesugaredType(
Context)) &&
16368 if (ConvertHalfVec)
16377 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
16378 if (!DRE->getQualifier())
16385 if (isa<FieldDecl>(VD) || isa<IndirectFieldDecl>(VD))
16388 return Method->isInstance();
16394 if (!ULE->getQualifier())
16399 if (Method->isInstance())
16420 if (pty->getKind() == BuiltinType::PseudoObject &&
16425 if (Opc == UO_Extension)
16430 if (Opc == UO_AddrOf &&
16431 (pty->getKind() == BuiltinType::Overload ||
16432 pty->getKind() == BuiltinType::UnknownAny ||
16433 pty->getKind() == BuiltinType::BoundMember))
16459 Expr *Input,
bool IsAfterAmp) {
16499 assert(SubStmt && isa<CompoundStmt>(SubStmt) &&
"Invalid action invocation!");
16504 assert(!Cleanup.exprNeedsCleanups() &&
16505 "cleanups within StmtExpr not correctly bound!");
16515 bool StmtExprMayBindToTemp =
false;
16518 if (
const auto *LastStmt =
16520 if (
const Expr *
Value = LastStmt->getExprStmt()) {
16521 StmtExprMayBindToTemp =
true;
16529 Expr *ResStmtExpr =
16531 if (StmtExprMayBindToTemp)
16533 return ResStmtExpr;
16556 auto *Cast = dyn_cast<ImplicitCastExpr>(E);
16557 if (Cast && Cast->getCastKind() == CK_ARCConsumeObject)
16558 return Cast->getSubExpr();
16579 return ExprError(
Diag(BuiltinLoc, diag::err_offsetof_record_type)
16580 << ArgTy << TypeRange);
16586 diag::err_offsetof_incomplete_type, TypeRange))
16589 bool DidWarnAboutNonPOD =
false;
16594 if (OC.isBrackets) {
16599 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_array_type)
16619 Comps.push_back(
OffsetOfNode(OC.LocStart, Exprs.size(), OC.LocEnd));
16620 Exprs.push_back(Idx);
16628 Comps.push_back(
OffsetOfNode(OC.LocStart, OC.U.IdentInfo, OC.LocEnd));
16635 diag::err_offsetof_incomplete_type))
16639 const RecordType *RC = CurrentType->
getAs<RecordType>();
16641 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_record_type)
16653 bool IsSafe =
LangOpts.CPlusPlus11? CRD->isStandardLayout() : CRD->isPOD();
16655 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
16656 : diag::ext_offsetof_non_pod_type;
16658 if (!IsSafe && !DidWarnAboutNonPOD &&
16661 <<
SourceRange(Components[0].LocStart, OC.LocEnd)
16663 DidWarnAboutNonPOD =
true;
16673 MemberDecl = IndirectMemberDecl->getAnonField();
16678 << OC.U.IdentInfo << RD <<
SourceRange(OC.LocStart,
16686 Diag(OC.LocEnd, diag::err_offsetof_bitfield)
16694 if (IndirectMemberDecl)
16702 if (Paths.getDetectedVirtual()) {
16703 Diag(OC.LocEnd, diag::err_offsetof_field_of_virtual_base)
16714 if (IndirectMemberDecl) {
16715 for (
auto *FI : IndirectMemberDecl->chain()) {
16716 assert(isa<FieldDecl>(FI));
16718 cast<FieldDecl>(FI), OC.LocEnd));
16721 Comps.push_back(
OffsetOfNode(OC.LocStart, MemberDecl, OC.LocEnd));
16727 Comps, Exprs, RParenLoc);
16753 assert((CondExpr && LHSExpr && RHSExpr) &&
"Missing type argument(s)");
16758 bool CondIsTrue =
false;
16763 llvm::APSInt condEval(32);
16765 CondExpr, &condEval, diag::err_typecheck_choose_expr_requires_constant);
16768 CondExpr = CondICE.
get();
16769 CondIsTrue = condEval.getZExtValue();
16772 Expr *ActiveExpr = CondIsTrue ? LHSExpr : RHSExpr;
16774 resType = ActiveExpr->
getType();
16780 resType, VK, OK, RPLoc, CondIsTrue);
16793 Decl *ManglingContextDecl;
16794 std::tie(MCtx, ManglingContextDecl) =
16798 Block->setBlockMangling(ManglingNumber, ManglingContextDecl);
16820 "block-id should have no identifier!");
16841 assert(T->isFunctionType() &&
16842 "GetTypeForDeclarator made a non-function block signature");
16858 unsigned Size =
Result.getFullDataSize();
16870 QualType RetTy = Fn->getReturnType();
16888 if (ExplicitSignature) {
16889 for (
unsigned I = 0, E = ExplicitSignature.
getNumParams(); I != E; ++I) {
16891 if (Param->getIdentifier() ==
nullptr && !Param->isImplicit() &&
16895 Diag(Param->getLocation(), diag::ext_parameter_name_omitted_c2x);
16897 Params.push_back(Param);
16903 for (
const auto &I : Fn->param_types()) {
16906 Params.push_back(Param);
16911 if (!Params.empty()) {
16922 AI->setOwningFunction(CurBlock->
TheDecl);
16925 if (AI->getIdentifier()) {
16931 if (AI->isInvalidDecl())
16954 Diag(CaretLoc, diag::err_blocks_disable) <<
LangOpts.OpenCL;
16959 assert(!Cleanup.exprNeedsCleanups() &&
16960 "cleanups within block not correctly bound!");
16973 bool NoReturn = BD->
hasAttr<NoReturnAttr>();
16981 if (NoReturn && !Ext.getNoReturn()) Ext = Ext.
withNoReturn(
true);
16984 if (isa<FunctionNoProtoType>(FTy)) {
17019 BD->
setBody(cast<CompoundStmt>(Body));
17021 if (Body &&
getCurFunction()->HasPotentialAvailabilityViolations)
17046 Expr *CopyExpr =
nullptr;
17048 if (
const RecordType *Record =
17055 if (isa<ParmVarDecl>(Var))
17074 if (!
Result.isInvalid() &&
17075 !
Result.get()->getType().isConstQualified()) {
17077 Result.get()->getType().withConst(),
17081 if (!
Result.isInvalid()) {
17091 if (!
Result.isInvalid() &&
17092 !cast<CXXConstructExpr>(
Result.get())->getConstructor()
17095 CopyExpr =
Result.get();
17102 Captures.push_back(NewCap);
17114 if (
Result->getBlockDecl()->hasCaptures()) {
17117 Cleanup.setExprNeedsCleanups(
true);
17121 for (
const auto &CI :
Result->getBlockDecl()->captures()) {
17122 const VarDecl *var = CI.getVariable();
17135 {Result},
Result->getType());
17149 Expr *OrigExpr = E;
17198 if (Init.isInvalid())
17200 E = Init.getAs<
Expr>();
17214 diag::err_first_argument_to_va_arg_not_of_type_va_list)
17219 diag::err_second_parameter_to_va_arg_incomplete,
17225 diag::err_second_parameter_to_va_arg_abstract,
17232 ? diag::warn_second_parameter_to_va_arg_ownership_qualified
17233 : diag::warn_second_parameter_to_va_arg_not_pod)
17262 if (
const auto *ET = UnderlyingType->
getAs<EnumType>())
17263 UnderlyingType = ET->getDecl()->getIntegerType();
17286 if (!PromoteType.
isNull())
17288 PDiag(diag::warn_second_parameter_to_va_arg_never_compatible)
17310 llvm_unreachable(
"I don't know size of pointer!");
17327 if ((SLDecl->isCompleteDefinition() || SLDecl->isBeingDefined()) &&
17336 S.
Diag(Loc, diag::err_std_source_location_impl_not_found);
17344 S.
Diag(Loc, diag::err_std_source_location_impl_malformed);
17348 unsigned Count = 0;
17350 StringRef Name = F->getName();
17352 if (Name ==
"_M_file_name") {
17353 if (F->getType() !=
17357 }
else if (Name ==
"_M_function_name") {
17358 if (F->getType() !=
17362 }
else if (Name ==
"_M_line") {
17363 if (!F->getType()->isIntegerType())
17366 }
else if (Name ==
"_M_column") {
17367 if (!F->getType()->isIntegerType())
17376 S.
Diag(Loc, diag::err_std_source_location_impl_malformed);
17440 if (OV->getSourceExpr())
17443 if (
auto *SL = dyn_cast<StringLiteral>(SrcExpr)) {
17445 !(ID && ID->getIdentifier()->isStr(
"NSString")))
17447 if (!SL->isOrdinary())
17451 Diag(SL->getBeginLoc(), diag::err_missing_atsign_prefix)
17458 if ((isa<IntegerLiteral>(SrcExpr) || isa<CharacterLiteral>(SrcExpr) ||
17459 isa<FloatingLiteral>(SrcExpr) || isa<ObjCBoolLiteralExpr>(SrcExpr) ||
17460 isa<CXXBoolLiteralExpr>(SrcExpr)) &&
17463 if (!ID || !ID->getIdentifier()->isStr(
"NSNumber"))
17481 const Expr *SrcExpr) {
17490 auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl());
17503 bool *Complained) {
17505 *Complained =
false;
17508 bool CheckInferredResultType =
false;
17510 unsigned DiagKind = 0;
17512 bool MayHaveConvFixit =
false;
17513 bool MayHaveFunctionDiff =
false;
17524 DiagKind = diag::err_typecheck_convert_pointer_int;
17527 DiagKind = diag::ext_typecheck_convert_pointer_int;
17530 MayHaveConvFixit =
true;
17534 DiagKind = diag::err_typecheck_convert_int_pointer;
17537 DiagKind = diag::ext_typecheck_convert_int_pointer;
17540 MayHaveConvFixit =
true;
17544 diag::warn_typecheck_convert_incompatible_function_pointer_strict;
17546 MayHaveConvFixit =
true;
17550 DiagKind = diag::err_typecheck_convert_incompatible_function_pointer;
17553 DiagKind = diag::ext_typecheck_convert_incompatible_function_pointer;
17556 MayHaveConvFixit =
true;
17560 DiagKind = diag::err_arc_typecheck_convert_incompatible_pointer;
17562 DiagKind = diag::err_typecheck_convert_incompatible_pointer;
17565 DiagKind = diag::ext_typecheck_convert_incompatible_pointer;
17569 if (!CheckInferredResultType) {
17571 }
else if (CheckInferredResultType) {
17575 MayHaveConvFixit =
true;
17579 DiagKind = diag::err_typecheck_convert_incompatible_pointer_sign;
17582 DiagKind = diag::ext_typecheck_convert_incompatible_pointer_sign;
17587 DiagKind = diag::err_typecheck_convert_pointer_void_func;
17590 DiagKind = diag::ext_typecheck_convert_pointer_void_func;
17602 DiagKind = diag::err_typecheck_incompatible_address_space;
17606 DiagKind = diag::err_typecheck_incompatible_ownership;
17610 llvm_unreachable(
"unknown error case for discarding qualifiers!");
17627 DiagKind = diag::err_typecheck_convert_discards_qualifiers;
17630 DiagKind = diag::ext_typecheck_convert_discards_qualifiers;
17637 DiagKind = diag::err_nested_pointer_qualifier_mismatch;
17639 DiagKind = diag::ext_nested_pointer_qualifier_mismatch;
17643 DiagKind = diag::err_typecheck_incompatible_nested_address_space;
17647 DiagKind = diag::err_int_to_block_pointer;
17651 DiagKind = diag::err_typecheck_convert_incompatible_block_pointer;
17658 for (
auto *srcProto : srcOPT->
quals()) {
17664 IFace = IFaceT->getDecl();
17669 for (
auto *dstProto : dstOPT->
quals()) {
17675 IFace = IFaceT->getDecl();
17678 DiagKind = diag::err_incompatible_qualified_id;
17681 DiagKind = diag::warn_incompatible_qualified_id;
17687 DiagKind = diag::err_incompatible_vectors;
17690 DiagKind = diag::warn_incompatible_vectors;
17694 DiagKind = diag::err_arc_weak_unavailable_assign;
17700 *Complained =
true;
17704 DiagKind = diag::err_typecheck_convert_incompatible;
17706 MayHaveConvFixit =
true;
17708 MayHaveFunctionDiff =
true;
17717 FirstType = DstType;
17718 SecondType = SrcType;
17728 FirstType = SrcType;
17729 SecondType = DstType;
17738 FDiag << FirstType << SecondType << ActionForDiag
17741 if (DiagKind == diag::ext_typecheck_convert_incompatible_pointer_sign ||
17742 DiagKind == diag::err_typecheck_convert_incompatible_pointer_sign) {
17752 if (!ConvHints.
isNull()) {
17757 if (MayHaveConvFixit) { FDiag << (
unsigned) (ConvHints.
Kind); }
17759 if (MayHaveFunctionDiff)
17763 if ((DiagKind == diag::warn_incompatible_qualified_id ||
17764 DiagKind == diag::err_incompatible_qualified_id) &&
17766 Diag(IFace->
getLocation(), diag::note_incomplete_class_and_qualified_id)
17773 if (CheckInferredResultType)
17780 *Complained =
true;
17791 return S.
Diag(Loc, diag::err_ice_not_integral)
17795 return S.
Diag(Loc, diag::err_expr_not_ice) << S.
LangOpts.CPlusPlus;
17810 IDDiagnoser(
unsigned DiagID)
17814 return S.
Diag(Loc, DiagID);
17816 } Diagnoser(DiagID);
17829 return S.
Diag(Loc, diag::ext_expr_not_ice) << S.
LangOpts.CPlusPlus;
17851 BaseDiagnoser(BaseDiagnoser) {}
17860 return S.
Diag(Loc, diag::err_ice_incomplete_type) << T;
17865 return S.
Diag(Loc, diag::err_ice_explicit_conversion) << T << ConvTy;
17876 return S.
Diag(Loc, diag::err_ice_ambiguous_conversion) << T;
17887 llvm_unreachable(
"conversion functions are permitted");
17889 } ConvertDiagnoser(Diagnoser);
17895 E = Converted.
get();
17910 E = RValueExpr.
get();
17917 if (!isa<ConstantExpr>(E))
17925 EvalResult.
Diag = &Notes;
17933 if (!isa<ConstantExpr>(E))
17948 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
17949 diag::note_invalid_subexpr_in_const_expr) {
17950 DiagLoc = Notes[0].first;
17954 if (!Folded || !CanFold) {
17976 class TransformToPE :
public TreeTransform<TransformToPE> {
17980 TransformToPE(
Sema &SemaRef) : BaseTransform(SemaRef) { }
17983 bool AlwaysRebuild() {
return true; }
17984 bool ReplacingOriginal() {
return true; }
17994 if (isa<FieldDecl>(E->
getDecl()) &&
17995 !SemaRef.isUnevaluatedContext())
17997 diag::err_invalid_non_static_member_use)
18000 return BaseTransform::TransformDeclRefExpr(E);
18008 return BaseTransform::TransformUnaryOperator(E);
18016 return SkipLambdaBody(E, Body);
18023 "Should only transform unevaluated expressions");
18028 return TransformToPE(*this).TransformExpr(E);
18033 "Should only transform unevaluated expressions");
18038 return TransformToPE(*this).TransformType(TInfo);
18046 LambdaContextDecl, ExprContext);
18053 .isDiscardedStatementContext();
18061 Prev.isImmediateFunctionContext() || Prev.isConstantEvaluated();
18064 Prev.InImmediateEscalatingFunctionContext;
18083 if (
const auto *E = dyn_cast<UnaryOperator>(PossibleDeref)) {
18084 if (E->getOpcode() == UO_Deref)
18085 return CheckPossibleDeref(S, E->getSubExpr());
18086 }
else if (
const auto *E = dyn_cast<ArraySubscriptExpr>(PossibleDeref)) {
18087 return CheckPossibleDeref(S, E->getBase());
18088 }
else if (
const auto *E = dyn_cast<MemberExpr>(PossibleDeref)) {
18089 return CheckPossibleDeref(S, E->getBase());
18090 }
else if (
const auto E = dyn_cast<DeclRefExpr>(PossibleDeref)) {
18094 Inner = Ptr->getPointeeType();
18096 Inner = Arr->getElementType();
18100 if (Inner->hasAttr(attr::NoDeref))
18110 const DeclRefExpr *DeclRef = CheckPossibleDeref(*
this, E);
18117 Diag(E->
getExprLoc(), diag::warn_dereference_of_noderef_type_no_decl)
18136 if (BO->getOpcode() == BO_Assign) {
18138 llvm::erase_value(LHSs, BO->getLHS());
18147 "Cannot mark an immediate escalating expression outside of an "
18148 "immediate escalating context");
18150 Call && Call->getCallee()) {
18151 if (
auto *DeclRef =
18152 dyn_cast<DeclRefExpr>(Call->getCallee()->IgnoreImplicit()))
18153 DeclRef->setIsImmediateEscalating(
true);
18154 }
else if (
auto *Ctr = dyn_cast<CXXConstructExpr>(E->
IgnoreImplicit())) {
18155 Ctr->setIsImmediateEscalating(
true);
18156 }
else if (
auto *DeclRef = dyn_cast<DeclRefExpr>(E->
IgnoreImplicit())) {
18157 DeclRef->setIsImmediateEscalating(
true);
18159 assert(
false &&
"expected an immediately escalating expression");
18176 if (
auto *DeclRef =
18177 dyn_cast<DeclRefExpr>(Call->getCallee()->IgnoreImplicit()))
18186 auto CheckConstantExpressionAndKeepResult = [&]() {
18189 Eval.
Diag = &Notes;
18191 Eval,
getASTContext(), ConstantExprKind::ImmediateInvocation);
18192 if (Res && Notes.empty()) {
18193 Cached = std::move(Eval.
Val);
18201 !CheckConstantExpressionAndKeepResult()) {
18206 if (Cleanup.exprNeedsCleanups()) {
18223 Cleanup.cleanupsHaveSideEffects(), {});
18236 ExprEvalContexts.back().ImmediateInvocationCandidates.emplace_back(Res, 0);
18244 Eval.
Diag = &Notes;
18247 Eval, SemaRef.
getASTContext(), ConstantExprKind::ImmediateInvocation);
18248 if (!
Result || !Notes.empty()) {
18251 if (
auto *
FunctionalCast = dyn_cast<CXXFunctionalCastExpr>(InnerExpr))
18254 if (
auto *Call = dyn_cast<CallExpr>(InnerExpr))
18256 else if (
auto *Call = dyn_cast<CXXConstructExpr>(InnerExpr))
18257 FD = Call->getConstructor();
18259 llvm_unreachable(
"unhandled decl kind");
18265 SemaRef.
Diag(
Context->Loc, diag::note_invalid_consteval_initializer)
18267 SemaRef.
Diag(
Context->Decl->getBeginLoc(), diag::note_declared_at);
18271 for (
auto &
Note : Notes)
18283 llvm::SmallPtrSetImpl<DeclRefExpr *> &DRSet;
18287 ComplexRemove(
Sema &SemaRef, llvm::SmallPtrSetImpl<DeclRefExpr *> &DR,
18290 4>::reverse_iterator Current)
18291 :
Base(SemaRef), DRSet(DR), IISet(II), CurrentII(Current) {}
18293 auto It = std::find_if(CurrentII, IISet.rend(),
18295 return Elem.getPointer() == E;
18301 if (It == IISet.rend()) {
18303 CurrentII->setInt(1);
18310 return Base::TransformConstantExpr(E);
18311 RemoveImmediateInvocation(E);
18312 return Base::TransformExpr(E->
getSubExpr());
18318 return Base::TransformCXXOperatorCallExpr(E);
18327 if (
auto *CE = dyn_cast<ConstantExpr>(Init))
18328 if (CE->isImmediateInvocation())
18329 RemoveImmediateInvocation(CE);
18330 return Base::TransformInitializer(Init, NotCopyInit);
18341 bool AlwaysRebuild() {
return false; }
18342 bool ReplacingOriginal() {
return true; }
18343 bool AllowSkippingCXXConstructExpr() {
18344 bool Res = AllowSkippingFirstCXXConstructExpr;
18345 AllowSkippingFirstCXXConstructExpr =
true;
18348 bool AllowSkippingFirstCXXConstructExpr =
true;
18358 if (isa<CXXConstructExpr>(It->getPointer()->IgnoreImplicit()))
18359 Transformer.AllowSkippingFirstCXXConstructExpr =
false;
18361 ExprResult Res = Transformer.TransformExpr(It->getPointer()->getSubExpr());
18367 It->getPointer()->setSubExpr(Res.
get());
18402 llvm::SmallPtrSetImpl<DeclRefExpr *> &DRSet;
18403 SimpleRemove(llvm::SmallPtrSetImpl<DeclRefExpr *> &S) : DRSet(S) {}
18406 return DRSet.size();
18409 Visitor.TraverseStmt(
18419 if (DR->isImmediateEscalating())
18423 if (
const auto *MD = dyn_cast<CXXMethodDecl>(ND);
18425 ND = MD->getParent();
18432 bool ImmediateEscalating =
false;
18433 bool IsPotentiallyEvaluated =
18443 SemaRef.
Diag(DR->getBeginLoc(), diag::err_invalid_consteval_take_address)
18444 << ND << isa<CXXRecordDecl>(ND) << FD->isConsteval();
18448 SemaRef.
Diag(
Context->Loc, diag::note_invalid_consteval_initializer)
18450 SemaRef.
Diag(
Context->Decl->getBeginLoc(), diag::note_declared_at);
18452 if (FD->isImmediateEscalating() && !FD->isConsteval())
18468 (Rec.
ExprContext == ExpressionKind::EK_TemplateArgument ||
18476 D = diag::err_lambda_unevaluated_operand;
18482 D = diag::err_lambda_in_constant_expression;
18483 }
else if (Rec.
ExprContext == ExpressionKind::EK_TemplateArgument) {
18486 D = diag::err_lambda_in_invalid_context;
18488 llvm_unreachable(
"Couldn't infer lambda error message.");
18490 for (
const auto *L : Rec.
Lambdas)
18491 Diag(L->getBeginLoc(), D);
18502 Diag(BO->getBeginLoc(), diag::warn_deprecated_simple_assign_volatile)
18575 llvm_unreachable(
"Invalid context");
18584 if (!TT.isOSWindows() || !TT.isX86())
18622 : FD(FD), Param(Param) {}
18629 CCName =
"stdcall";
18632 CCName =
"fastcall";
18635 CCName =
"vectorcall";
18638 llvm_unreachable(
"CC does not need mangling");
18641 S.
Diag(Loc, diag::err_cconv_incomplete_param_type)
18642 << Param->getDeclName() << FD->
getDeclName() << CCName;
18647 ParamIncompleteTypeDiagnoser Diagnoser(FD, Param);
18653enum class OdrUseContext {
18675 return OdrUseContext::None;
18680 Result = OdrUseContext::Used;
18684 Result = OdrUseContext::FormallyOdrUsed;
18690 Result = OdrUseContext::FormallyOdrUsed;
18695 return OdrUseContext::Dependent;
18706 auto *CCD = dyn_cast<CXXConstructorDecl>(Func);
18707 return CCD && CCD->getInheritedConstructor();
18713 bool MightBeOdrUse) {
18714 assert(Func &&
"No function?");
18729 OdrUseContext OdrUse =
18731 if (IsRecursiveCall && OdrUse == OdrUseContext::Used)
18732 OdrUse = OdrUseContext::FormallyOdrUsed;
18737 OdrUse == OdrUseContext::Used) {
18738 if (
auto *Constructor = dyn_cast<CXXConstructorDecl>(Func))
18739 if (Constructor->isDefaultConstructor())
18740 OdrUse = OdrUseContext::FormallyOdrUsed;
18741 if (isa<CXXDestructorDecl>(Func))
18742 OdrUse = OdrUseContext::FormallyOdrUsed;
18749 bool NeededForConstantEvaluation =
18774 bool NeedDefinition = !IsRecursiveCall && (OdrUse == OdrUseContext::Used ||
18775 NeededForConstantEvaluation);
18782 if (NeedDefinition &&
18791 if (NeedDefinition && !Func->
getBody()) {
18794 dyn_cast<CXXConstructorDecl>(Func)) {
18796 if (Constructor->isDefaulted() && !Constructor->isDeleted()) {
18797 if (Constructor->isDefaultConstructor()) {
18798 if (Constructor->isTrivial() &&
18799 !Constructor->hasAttr<DLLExportAttr>())
18802 }
else if (Constructor->isCopyConstructor()) {
18804 }
else if (Constructor->isMoveConstructor()) {
18807 }
else if (Constructor->getInheritedConstructor()) {
18811 dyn_cast<CXXDestructorDecl>(Func)) {
18813 if (Destructor->isDefaulted() && !Destructor->isDeleted()) {
18814 if (Destructor->isTrivial() && !Destructor->hasAttr<DLLExportAttr>())
18818 if (Destructor->isVirtual() &&
getLangOpts().AppleKext)
18820 }
else if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(Func)) {
18821 if (MethodDecl->isOverloadedOperator() &&
18822 MethodDecl->getOverloadedOperator() == OO_Equal) {
18824 if (MethodDecl->isDefaulted() && !MethodDecl->isDeleted()) {
18825 if (MethodDecl->isCopyAssignmentOperator())
18827 else if (MethodDecl->isMoveAssignmentOperator())
18830 }
else if (isa<CXXConversionDecl>(MethodDecl) &&
18831 MethodDecl->getParent()->isLambda()) {
18838 }
else if (MethodDecl->isVirtual() &&
getLangOpts().AppleKext)
18854 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
18855 if (FirstInstantiation) {
18856 PointOfInstantiation = Loc;
18858 MSI->setPointOfInstantiation(Loc);
18866 PointOfInstantiation = Loc;
18875 std::make_pair(Func, PointOfInstantiation));
18884 std::make_pair(Func, PointOfInstantiation));
18891 for (
auto *i : Func->
redecls()) {
18892 if (!i->isUsed(
false) && i->isImplicitlyInstantiable())
18905 Constructor->isImmediateFunction()
18910 if (Init->isInClassMemberInitializer())
18912 MarkDeclarationsReferencedInExpr(Init->getInit());
18931 if (OdrUse == OdrUseContext::Used && !Func->
isUsed(
false)) {
18934 if (mightHaveNonExternalLinkage(Func))
18957 if (
auto *Dtor = dyn_cast<CXXDestructorDecl>(Func)) {
18959 if (
Parent->getNumVBases() > 0 && !Dtor->getBody())
18977 const unsigned *
const FunctionScopeIndexToStopAt =
nullptr) {
18981 assert(Var &&
"expected a capturable variable");
18991 QualType CaptureType, DeclRefType;
18997 DeclRefType, FunctionScopeIndexToStopAt);
19000 auto *FD = dyn_cast_or_null<FunctionDecl>(SemaRef.
CurContext);
19009 if (SemaRef.
LangOpts.CUDAIsDevice) {
19010 SemaRef.
targetDiag(Loc, diag::err_ref_bad_target)
19011 << 2 << 1 << Var << UserTarget;
19014 ? diag::note_cuda_const_var_unpromoted
19015 : diag::note_cuda_host_var);
19032 else if (SemaRef.
LangOpts.GPURelocatableDeviceCode)
19042 unsigned CapturingScopeIndex) {
19053 if (isa<ParmVarDecl>(var) &&
19054 isa<TranslationUnitDecl>(VarDC))
19068 unsigned ContextKind = 3;
19069 if (isa<CXXMethodDecl>(VarDC) &&
19070 cast<CXXRecordDecl>(VarDC->
getParent())->isLambda()) {
19072 }
else if (isa<FunctionDecl>(VarDC)) {
19074 }
else if (isa<BlockDecl>(VarDC)) {
19078 S.
Diag(loc, diag::err_reference_to_local_in_enclosing_context)
19079 << var << ValueKind << ContextKind << VarDC;
19089 bool &SubCapturesAreNested,
19095 SubCapturesAreNested =
true;
19108 !(isa<LambdaScopeInfo>(CSI) && cast<LambdaScopeInfo>(CSI)->Mutable) &&
19109 !(isa<CapturedRegionScopeInfo>(CSI) &&
19110 cast<CapturedRegionScopeInfo>(CSI)->CapRegionKind ==
CR_OpenMP))
19142 assert((isa<VarDecl, BindingDecl>(Var)) &&
19143 "Only variables and structured bindings can be captured");
19154 S.
Diag(Loc, diag::err_lambda_capture_anonymous_var);
19163 S.
Diag(Loc, diag::err_ref_vm_type);
19170 if (
const RecordType *VTTy = Var->
getType()->
getAs<RecordType>()) {
19171 if (VTTy->getDecl()->hasFlexibleArrayMember()) {
19174 S.
Diag(Loc, diag::err_ref_flexarray_type);
19176 S.
Diag(Loc, diag::err_lambda_capture_flexarray_type) << Var;
19182 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
19185 if (HasBlocksAttr && (IsLambda || isa<CapturedRegionScopeInfo>(CSI))) {
19187 S.
Diag(Loc, diag::err_capture_block_variable) << Var << !IsLambda;
19196 S.
Diag(Loc, diag::err_opencl_block_ref_block);
19200 if (isa<BindingDecl>(Var)) {
19207 ? diag::warn_cxx17_compat_capture_binding
19208 : diag::ext_capture_binding)
19222 bool ByRef =
false;
19228 if (BuildAndDiagnose) {
19229 S.
Diag(Loc, diag::err_ref_array_type);
19240 if (BuildAndDiagnose) {
19241 S.
Diag(Loc, diag::err_arc_autoreleasing_capture)
19257 if (BuildAndDiagnose) {
19259 S.
Diag(Loc, diag::warn_block_capture_autoreleasing);
19260 S.
Diag(VarLoc, diag::note_declare_parameter_strong);
19265 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
19274 DeclRefType = CaptureType;
19278 if (BuildAndDiagnose)
19288 const bool BuildAndDiagnose,
QualType &CaptureType,
QualType &DeclRefType,
19315 CaptureType = DeclRefType;
19318 if (BuildAndDiagnose)
19319 RSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
19329 const bool RefersToCapturedVariable,
19334 bool ByRef =
false;
19338 ByRef = (LSI->
ImpCaptureStyle == LambdaScopeInfo::ImpCap_LambdaByref);
19344 if (BuildAndDiagnose) {
19345 S.
Diag(Loc, diag::err_capture_binding_openmp) << Var;
19353 S.
Diag(Loc, diag::err_wasm_ca_reference) << 0;
19384 if (!RefType->getPointeeType()->isFunctionType())
19391 if (BuildAndDiagnose) {
19392 S.
Diag(Loc, diag::err_arc_autoreleasing_capture) << 1;
19402 if (!
Invalid && BuildAndDiagnose) {
19406 diag::err_capture_of_incomplete_or_sizeless_type,
19410 diag::err_capture_of_abstract_type))
19430 if (BuildAndDiagnose)
19431 LSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
19432 Loc, EllipsisLoc, CaptureType,
Invalid);
19443 if (T.isTriviallyCopyableType(
Context))
19447 if (!(RD = RD->getDefinition()))
19449 if (RD->hasSimpleCopyConstructor())
19451 if (RD->hasUserDeclaredCopyConstructor())
19453 if (Ctor->isCopyConstructor())
19454 return !Ctor->isDeleted();
19474 if (ShouldOfferCopyFix) {
19478 FixBuffer.assign({Separator, Var->
getName()});
19479 Sema.
Diag(VarInsertLoc, diag::note_lambda_variable_capture_fixit)
19484 FixBuffer.assign({Separator,
"&", Var->
getName()});
19485 Sema.
Diag(VarInsertLoc, diag::note_lambda_variable_capture_fixit)
19497 return !C.isThisCapture() && !C.isInitCapture();
19506 if (ShouldOfferCopyFix) {
19507 bool CanDefaultCopyCapture =
true;
19516 if (CanDefaultCopyCapture && llvm::none_of(LSI->
Captures, [](
Capture &
C) {
19517 return !C.isThisCapture() && !C.isInitCapture() && C.isCopyCapture();
19519 FixBuffer.assign({
"=", Separator});
19520 Sema.
Diag(DefaultInsertLoc, diag::note_lambda_default_capture_fixit)
19529 return !C.isInitCapture() && C.isReferenceCapture() &&
19530 !C.isThisCapture();
19532 FixBuffer.assign({
"&", Separator});
19533 Sema.
Diag(DefaultInsertLoc, diag::note_lambda_default_capture_fixit)
19542 QualType &DeclRefType,
const unsigned *
const FunctionScopeIndexToStopAt) {
19555 const auto *VD = dyn_cast<VarDecl>(Var);
19557 if (VD->isInitCapture())
19562 assert(VD &&
"Cannot capture a null variable");
19564 const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt
19568 if (FunctionScopeIndexToStopAt) {
19570 while (FSIndex != MaxFunctionScopesIndex) {
19578 bool IsGlobal = !VD->hasLocalStorage();
19581 MaxFunctionScopesIndex)))
19584 if (isa<VarDecl>(Var))
19595 CaptureType = Var->
getType();
19597 bool Nested =
false;
19599 unsigned FunctionScopesIndex = MaxFunctionScopesIndex;
19604 LSI = dyn_cast_or_null<LambdaScopeInfo>(
19607 bool IsInScopeDeclarationContext =
19618 if (IsInScopeDeclarationContext &&
19619 FunctionScopesIndex == MaxFunctionScopesIndex && VarDC == DC)
19625 if (
const auto *Parm = dyn_cast<ParmVarDecl>(Var);
19626 Parm && Parm->getDeclContext() == DC)
19632 !IsInScopeDeclarationContext
19635 BuildAndDiagnose, *
this);
19641 FunctionScopesIndex = MaxFunctionScopesIndex - 1;
19661 if (BuildAndDiagnose) {
19664 Diag(ExprLoc, diag::err_lambda_impcap) << Var;
19679 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
19680 QTy = PVD->getOriginalType();
19685 if (
auto *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
19691 Var, RSI->OpenMPLevel, RSI->OpenMPCaptureLevel);
19696 if (IsOpenMPPrivateDecl != OMPC_unknown &&
19699 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
19700 QTy = PVD->getOriginalType();
19701 for (
int I = 1, E = getNumberOfConstructScopes(RSI->OpenMPLevel);
19705 assert(RSI->OpenMPLevel == OuterRSI->OpenMPLevel &&
19706 "Wrong number of captured regions associated with the "
19707 "OpenMP construct.");
19712 IsOpenMPPrivateDecl != OMPC_private &&
19714 RSI->OpenMPCaptureLevel);
19718 RSI->OpenMPCaptureLevel);
19724 adjustOpenMPTargetScopeIndex(FunctionScopesIndex, RSI->OpenMPLevel);
19726 if (IsTargetCap || IsOpenMPPrivateDecl == OMPC_private ||
19727 (IsGlobal && !IsGlobalCap)) {
19728 Nested = !IsTargetCap;
19743 if (BuildAndDiagnose) {
19744 Diag(ExprLoc, diag::err_lambda_impcap) << Var;
19766 FunctionScopesIndex--;
19767 if (IsInScopeDeclarationContext)
19769 }
while (!VarDC->
Equals(DC));
19777 for (
unsigned I = ++FunctionScopesIndex,
N = MaxFunctionScopesIndex + 1; I !=
N;
19790 if (
Invalid && !BuildAndDiagnose)
19795 DeclRefType, Nested, *
this,
Invalid);
19799 RSI, Var, ExprLoc, BuildAndDiagnose, CaptureType, DeclRefType, Nested,
19800 Kind, I ==
N - 1, *
this,
Invalid);
19806 DeclRefType, Nested, Kind, EllipsisLoc,
19811 if (
Invalid && !BuildAndDiagnose)
19823 DeclRefType,
nullptr);
19830 false, CaptureType,
19831 DeclRefType,
nullptr);
19840 false, CaptureType,
19841 DeclRefType,
nullptr))
19844 return DeclRefType;
19852class CopiedTemplateArgs {
19856 template<
typename RefExpr>
19857 CopiedTemplateArgs(RefExpr *E) : HasArgs(E->hasExplicitTemplateArgs()) {
19859 E->copyTemplateArgumentsInto(TemplateArgStorage);
19862#ifdef __has_cpp_attribute
19863#if __has_cpp_attribute(clang::lifetimebound)
19864 [[clang::lifetimebound]]
19868 return HasArgs ? &TemplateArgStorage :
nullptr;
19894 auto Rebuild = [&](
Expr *Sub) {
19899 auto IsPotentialResultOdrUsed = [&](
NamedDecl *D) {
19902 auto *VD = dyn_cast<VarDecl>(D);
19925 llvm_unreachable(
"unexpected non-odr-use-reason");
19929 if (VD->getType()->isReferenceType())
19931 if (
auto *RD = VD->getType()->getAsCXXRecordDecl())
19932 if (RD->hasMutableFields())
19934 if (!VD->isUsableInConstantExpressions(S.
Context))
19939 if (VD->getType()->isReferenceType())
19947 auto MarkNotOdrUsed = [&] {
19950 LSI->markVariableExprAsNonODRUsed(E);
19957 case Expr::DeclRefExprClass: {
19959 if (DRE->isNonOdrUse() || IsPotentialResultOdrUsed(DRE->getDecl()))
19965 S.
Context, DRE->getQualifierLoc(), DRE->getTemplateKeywordLoc(),
19966 DRE->getDecl(), DRE->refersToEnclosingVariableOrCapture(),
19967 DRE->getNameInfo(), DRE->getType(), DRE->getValueKind(),
19968 DRE->getFoundDecl(), CopiedTemplateArgs(DRE), NOUR);
19971 case Expr::FunctionParmPackExprClass: {
19976 if (IsPotentialResultOdrUsed(D))
19987 case Expr::ArraySubscriptExprClass: {
19993 if (!
Base.isUsable())
19995 Expr *LHS = ASE->getBase() == ASE->getLHS() ?
Base.get() : ASE->getLHS();
19996 Expr *RHS = ASE->getBase() == ASE->getRHS() ?
Base.get() : ASE->getRHS();
19999 ASE->getRBracketLoc());
20002 case Expr::MemberExprClass: {
20006 if (isa<FieldDecl>(ME->getMemberDecl())) {
20008 if (!
Base.isUsable())
20011 S.
Context,
Base.get(), ME->isArrow(), ME->getOperatorLoc(),
20012 ME->getQualifierLoc(), ME->getTemplateKeywordLoc(),
20013 ME->getMemberDecl(), ME->getFoundDecl(), ME->getMemberNameInfo(),
20014 CopiedTemplateArgs(ME), ME->getType(), ME->getValueKind(),
20015 ME->getObjectKind(), ME->isNonOdrUse());
20018 if (ME->getMemberDecl()->isCXXInstanceMember())
20023 if (ME->isNonOdrUse() || IsPotentialResultOdrUsed(ME->getMemberDecl()))
20029 S.
Context, ME->getBase(), ME->isArrow(), ME->getOperatorLoc(),
20030 ME->getQualifierLoc(), ME->getTemplateKeywordLoc(), ME->getMemberDecl(),
20031 ME->getFoundDecl(), ME->getMemberNameInfo(), CopiedTemplateArgs(ME),
20032 ME->getType(), ME->getValueKind(), ME->getObjectKind(), NOUR);
20035 case Expr::BinaryOperatorClass: {
20037 Expr *LHS = BO->getLHS();
20038 Expr *RHS = BO->getRHS();
20040 if (BO->getOpcode() == BO_PtrMemD) {
20042 if (!Sub.isUsable())
20046 }
else if (BO->getOpcode() == BO_Comma) {
20048 if (!Sub.isUsable())
20054 return S.
BuildBinOp(
nullptr, BO->getOperatorLoc(), BO->getOpcode(),
20059 case Expr::ParenExprClass: {
20062 if (!Sub.isUsable())
20064 return S.
ActOnParenExpr(PE->getLParen(), PE->getRParen(), Sub.get());
20069 case Expr::ConditionalOperatorClass: {
20080 LHS = CO->getLHS();
20082 RHS = CO->getRHS();
20084 CO->getCond(), LHS.
get(), RHS.
get());
20089 case Expr::UnaryOperatorClass: {
20091 if (UO->getOpcode() != UO_Extension)
20094 if (!Sub.isUsable())
20096 return S.
BuildUnaryOp(
nullptr, UO->getOperatorLoc(), UO_Extension,
20103 case Expr::GenericSelectionExprClass: {
20107 bool AnyChanged =
false;
20108 for (
Expr *OrigAssocExpr : GSE->getAssocExprs()) {
20109 ExprResult AssocExpr = Rebuild(OrigAssocExpr);
20113 AssocExprs.push_back(AssocExpr.
get());
20116 AssocExprs.push_back(OrigAssocExpr);
20120 void *ExOrTy =
nullptr;
20121 bool IsExpr = GSE->isExprPredicate();
20123 ExOrTy = GSE->getControllingExpr();
20125 ExOrTy = GSE->getControllingType();
20127 GSE->getGenericLoc(), GSE->getDefaultLoc(),
20128 GSE->getRParenLoc(), IsExpr, ExOrTy,
20129 GSE->getAssocTypeSourceInfos(), AssocExprs)
20137 case Expr::ChooseExprClass: {
20148 if (!LHS.
get() && !RHS.
get())
20151 LHS = CE->getLHS();
20153 RHS = CE->getRHS();
20156 RHS.
get(), CE->getRParenLoc());
20160 case Expr::ConstantExprClass: {
20163 if (!Sub.isUsable())
20170 case Expr::ImplicitCastExprClass: {
20175 switch (ICE->getCastKind()) {
20177 case CK_DerivedToBase:
20178 case CK_UncheckedDerivedToBase: {
20179 ExprResult Sub = Rebuild(ICE->getSubExpr());
20180 if (!Sub.isUsable())
20184 ICE->getValueKind(), &Path);
20243 for (
Expr *E : LocalMaybeODRUseExprs) {
20244 if (
auto *DRE = dyn_cast<DeclRefExpr>(E)) {
20246 DRE->getLocation(), *
this);
20247 }
else if (
auto *ME = dyn_cast<MemberExpr>(E)) {
20250 }
else if (
auto *FP = dyn_cast<FunctionParmPackExpr>(E)) {
20254 llvm_unreachable(
"Unexpected expression");
20259 "MarkVarDeclODRUsed failed to cleanup MaybeODRUseExprs?");
20268 const bool RefersToEnclosingScope =
20271 if (RefersToEnclosingScope) {
20286 assert(E &&
"Capture variable should be used in an expression.");
20297 assert((!E || isa<DeclRefExpr>(E) || isa<MemberExpr>(E) ||
20298 isa<FunctionParmPackExpr>(E)) &&
20299 "Invalid Expr argument to DoMarkVarDeclReferenced");
20310 bool UsableInConstantExpr =
20322 bool NeededForConstantEvaluation =
20325 bool NeedDefinition =
20326 OdrUse == OdrUseContext::Used || NeededForConstantEvaluation;
20328 assert(!isa<VarTemplatePartialSpecializationDecl>(Var) &&
20329 "Can't instantiate a partial template specialization.");
20335 !isa<VarTemplateSpecializationDecl>(Var))
20346 bool TryInstantiating =
20350 if (TryInstantiating) {
20353 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
20354 if (FirstInstantiation) {
20355 PointOfInstantiation = Loc;
20357 MSI->setPointOfInstantiation(PointOfInstantiation);
20363 if (UsableInConstantExpr) {
20372 if (
auto *DRE = dyn_cast_or_null<DeclRefExpr>(E))
20373 DRE->setDecl(DRE->getDecl());
20374 else if (
auto *ME = dyn_cast_or_null<MemberExpr>(E))
20375 ME->setMemberDecl(ME->getMemberDecl());
20376 }
else if (FirstInstantiation) {
20378 .push_back(std::make_pair(Var, PointOfInstantiation));
20380 bool Inserted =
false;
20382 auto Iter = llvm::find_if(
20384 return P.first == Var;
20386 if (Iter != I.end()) {
20399 if (isa<VarTemplateSpecializationDecl>(Var) && !Inserted)
20401 .push_back(std::make_pair(Var, PointOfInstantiation));
20425 if (
DeclRefExpr *DRE = dyn_cast_or_null<DeclRefExpr>(E))
20426 if (DRE->isNonOdrUse())
20428 if (
MemberExpr *ME = dyn_cast_or_null<MemberExpr>(E))
20429 if (ME->isNonOdrUse())
20433 case OdrUseContext::None:
20436 assert((!E || isa<FunctionParmPackExpr>(E) ||
20438 "missing non-odr-use marking for unevaluated decl ref");
20441 case OdrUseContext::FormallyOdrUsed:
20446 case OdrUseContext::Used:
20455 case OdrUseContext::Dependent:
20473 if (OdrUse == OdrUseContext::Used) {
20474 QualType CaptureType, DeclRefType;
20480 }
else if (OdrUse == OdrUseContext::Dependent) {
20494 bool MightBeOdrUse,
20499 if (
VarDecl *Var = dyn_cast<VarDecl>(D)) {
20513 const MemberExpr *ME = dyn_cast<MemberExpr>(E);
20520 bool IsVirtualCall = MD->
isVirtual() &&
20522 if (!IsVirtualCall)
20541 bool OdrUse =
true;
20543 if (Method->isVirtual() &&
20547 if (
auto *FD = dyn_cast<FunctionDecl>(E->
getDecl())) {
20552 !FD->isDependentContext())
20567 bool MightBeOdrUse =
true;
20570 if (Method->isPure())
20571 MightBeOdrUse =
false;
20591 bool MightBeOdrUse) {
20592 if (MightBeOdrUse) {
20593 if (
auto *VD = dyn_cast<VarDecl>(D)) {
20598 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
20626bool MarkReferencedDecls::TraverseTemplateArgument(
20640 return Inherited::TraverseTemplateArgument(Arg);
20644 MarkReferencedDecls Marker(*
this, Loc);
20645 Marker.TraverseType(T);
20651class EvaluatedExprMarker :
public UsedDeclVisitor<EvaluatedExprMarker> {
20654 bool SkipLocalVariables;
20657 EvaluatedExprMarker(
Sema &S,
bool SkipLocalVariables,
20659 : Inherited(S), SkipLocalVariables(SkipLocalVariables), StopAt(StopAt) {}
20665 void Visit(
Expr *E) {
20666 if (llvm::is_contained(StopAt, E))
20668 Inherited::Visit(E);
20678 if (SkipLocalVariables) {
20680 if (VD->hasLocalStorage())
20704 bool SkipLocalVariables,
20706 EvaluatedExprMarker(*
this, SkipLocalVariables, StopAt).Visit(E);
20728 if (
auto *VD = dyn_cast_or_null<VarDecl>(
20730 if (VD->isConstexpr() ||
20731 (VD->isStaticDataMember() && VD->isFirstDecl() && !VD->isInline()))
20803 class CallReturnIncompleteDiagnoser :
public TypeDiagnoser {
20809 : FD(FD), CE(CE) { }
20813 S.
Diag(Loc, diag::err_call_incomplete_return)
20818 S.
Diag(Loc, diag::err_call_function_incomplete_return)
20823 } Diagnoser(FD, CE);
20836 unsigned diagnostic = diag::warn_condition_is_assignment;
20837 bool IsOrAssign =
false;
20840 if (Op->getOpcode() != BO_Assign && Op->getOpcode() != BO_OrAssign)
20843 IsOrAssign = Op->getOpcode() == BO_OrAssign;
20852 diagnostic = diag::warn_condition_is_idiomatic_assignment;
20856 diagnostic = diag::warn_condition_is_idiomatic_assignment;
20859 Loc = Op->getOperatorLoc();
20861 if (Op->getOperator() != OO_Equal && Op->getOperator() != OO_PipeEqual)
20864 IsOrAssign = Op->getOperator() == OO_PipeEqual;
20865 Loc = Op->getOperatorLoc();
20877 Diag(Loc, diag::note_condition_assign_silence)
20882 Diag(Loc, diag::note_condition_or_assign_to_comparison)
20885 Diag(Loc, diag::note_condition_assign_to_comparison)
20903 if (opE->getOpcode() == BO_EQ &&
20904 opE->getLHS()->IgnoreParenImpCasts()->isModifiableLvalue(
Context)
20910 Diag(Loc, diag::note_equality_comparison_silence)
20913 Diag(Loc, diag::note_equality_comparison_to_assign)
20919 bool IsConstexpr) {
20921 if (
ParenExpr *parenE = dyn_cast<ParenExpr>(E))
20938 if (!T->isScalarType()) {
20939 Diag(Loc, diag::err_typecheck_statement_requires_scalar)
20943 CheckBoolLikeConversion(E, Loc);
20971 if (
Cond.isInvalid()) {
20989 struct RebuildUnknownAnyFunction
20990 :
StmtVisitor<RebuildUnknownAnyFunction, ExprResult> {
20994 RebuildUnknownAnyFunction(
Sema &S) : S(S) {}
20997 llvm_unreachable(
"unexpected statement!");
21008 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
21009 ExprResult SubResult = Visit(E->getSubExpr());
21012 Expr *SubExpr = SubResult.
get();
21013 E->setSubExpr(SubExpr);
21014 E->setType(SubExpr->
getType());
21021 return rebuildSugarExpr(E);
21025 return rebuildSugarExpr(E);
21032 Expr *SubExpr = SubResult.
get();
21041 if (!isa<FunctionDecl>(VD))
return VisitExpr(E);
21047 !(isa<CXXMethodDecl>(VD) &&
21048 cast<CXXMethodDecl>(VD)->isInstance()))
21059 return resolveDecl(E, E->
getDecl());
21077 struct RebuildUnknownAnyExpr
21078 :
StmtVisitor<RebuildUnknownAnyExpr, ExprResult> {
21089 llvm_unreachable(
"unexpected statement!");
21103 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
21104 ExprResult SubResult = Visit(E->getSubExpr());
21106 Expr *SubExpr = SubResult.
get();
21107 E->setSubExpr(SubExpr);
21108 E->setType(SubExpr->
getType());
21115 return rebuildSugarExpr(E);
21119 return rebuildSugarExpr(E);
21157 return resolveDecl(E, E->
getDecl());
21168 FK_FunctionPointer,
21175 assert(isa<CXXMemberCallExpr>(E) || isa<CXXOperatorCallExpr>(E));
21176 Kind = FK_MemberFunction;
21180 Kind = FK_FunctionPointer;
21183 Kind = FK_BlockPointer;
21189 unsigned diagID = diag::err_func_returning_array_function;
21190 if (Kind == FK_BlockPointer)
21191 diagID = diag::err_block_returning_array_function;
21227 if (ParamTypes.empty() && Proto->
isVariadic()) {
21229 for (
unsigned i = 0, e = E->
getNumArgs(); i != e; ++i) {
21232 ParamTypes = ArgTypes;
21243 case FK_MemberFunction:
21247 case FK_FunctionPointer:
21251 case FK_BlockPointer:
21257 ExprResult CalleeResult = Visit(CalleeExpr);
21268 S.
Diag(E->
getExprLoc(), diag::err_func_returning_array_function)
21276 Method->setReturnType(DestType);
21288 if (E->
getCastKind() == CK_FunctionToPointerDecay) {
21302 }
else if (E->
getCastKind() == CK_LValueToRValue) {
21306 assert(isa<BlockPointerType>(E->
getType()));
21319 llvm_unreachable(
"Unhandled cast type!");
21352 if (DRE && Proto && Proto->getParamTypes().empty() && Proto->isVariadic()) {
21355 S.
Context, FD->getDeclContext(), Loc, Loc,
21356 FD->getNameInfo().getName(), DestType, FD->getTypeSourceInfo(),
21358 false , FD->hasPrototype(),
21361 if (FD->getQualifier())
21365 for (
const auto &AI : FT->param_types()) {
21369 Params.push_back(Param);
21371 NewFD->setParams(Params);
21378 if (MD->isInstance()) {
21388 }
else if (isa<VarDecl>(VD)) {
21392 S.
Diag(E->
getExprLoc(), diag::err_unknown_any_var_function_type)
21420 diag::err_typecheck_cast_to_incomplete))
21435 return RebuildUnknownAnyExpr(*
this, ToType).Visit(E);
21442 ExplicitCastExpr *castArg = dyn_cast<ExplicitCastExpr>(arg->IgnoreParens());
21451 assert(!arg->hasPlaceholderType());
21463 unsigned diagID = diag::err_uncasted_use_of_unknown_any;
21466 if (
CallExpr *call = dyn_cast<CallExpr>(E)) {
21467 E = call->getCallee();
21468 diagID = diag::err_uncasted_call_of_unknown_any;
21476 if (
DeclRefExpr *ref = dyn_cast<DeclRefExpr>(E)) {
21477 loc = ref->getLocation();
21478 d = ref->getDecl();
21479 }
else if (
MemberExpr *mem = dyn_cast<MemberExpr>(E)) {
21480 loc = mem->getMemberLoc();
21481 d = mem->getMemberDecl();
21483 diagID = diag::err_uncasted_call_of_unknown_any;
21484 loc = msg->getSelectorStartLoc();
21485 d = msg->getMethodDecl();
21487 S.
Diag(loc, diag::err_uncasted_send_to_unknown_any_method)
21488 <<
static_cast<unsigned>(msg->isClassMessage()) << msg->getSelector()
21517 if (!placeholderType)
return E;
21519 switch (placeholderType->
getKind()) {
21522 case BuiltinType::Overload: {
21542 case BuiltinType::BoundMember: {
21547 if (isa<CXXPseudoDestructorExpr>(BME)) {
21548 PD =
PDiag(diag::err_dtor_expr_without_call) << 1;
21549 }
else if (
const auto *ME = dyn_cast<MemberExpr>(BME)) {
21550 if (ME->getMemberNameInfo().getName().getNameKind() ==
21552 PD =
PDiag(diag::err_dtor_expr_without_call) << 0;
21560 case BuiltinType::ARCUnbridgedCast: {
21567 case BuiltinType::UnknownAny:
21571 case BuiltinType::PseudoObject:
21574 case BuiltinType::BuiltinFn: {
21579 unsigned BuiltinID = FD->getBuiltinID();
21580 if (BuiltinID == Builtin::BI__noop) {
21582 CK_BuiltinFnToFnPtr)
21595 ? diag::err_use_of_unaddressable_function
21596 : diag::warn_cxx20_compat_use_of_unaddressable_function);
21597 if (FD->isImplicitlyInstantiable()) {
21624 case BuiltinType::IncompleteMatrixIdx:
21628 diag::err_matrix_incomplete_index);
21632 case BuiltinType::OMPArraySection:
21637 case BuiltinType::OMPArrayShaping:
21640 case BuiltinType::OMPIterator:
21644#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
21645 case BuiltinType::Id:
21646#include "clang/Basic/OpenCLImageTypes.def"
21647#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
21648 case BuiltinType::Id:
21649#include "clang/Basic/OpenCLExtensionTypes.def"
21650#define SVE_TYPE(Name, Id, SingletonId) \
21651 case BuiltinType::Id:
21652#include "clang/Basic/AArch64SVEACLETypes.def"
21653#define PPC_VECTOR_TYPE(Name, Id, Size) \
21654 case BuiltinType::Id:
21655#include "clang/Basic/PPCTypes.def"
21656#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
21657#include "clang/Basic/RISCVVTypes.def"
21658#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
21659#include "clang/Basic/WebAssemblyReferenceTypes.def"
21660#define BUILTIN_TYPE(Id, SingletonId) case BuiltinType::Id:
21661#define PLACEHOLDER_TYPE(Id, SingletonId)
21662#include "clang/AST/BuiltinTypes.def"
21666 llvm_unreachable(
"invalid placeholder type!");
21680 assert((Kind == tok::kw___objc_yes || Kind == tok::kw___objc_no) &&
21681 "Unknown Objective-C Boolean value!");
21701 auto FindSpecVersion =
21702 [&](StringRef Platform) -> std::optional<VersionTuple> {
21708 if (Spec == AvailSpecs.end() && Platform ==
"maccatalyst") {
21713 if (Spec == AvailSpecs.end())
21714 return std::nullopt;
21718 VersionTuple Version;
21719 if (
auto MaybeVersion =
21721 Version = *MaybeVersion;
21726 Context->HasPotentialAvailabilityViolations =
true;
21740 if (T.isNull() || T->isUndeducedType() ||
Defines the clang::ASTContext interface.
This file provides some common utility functions for processing Lambda related AST Constructs.
static bool isObjCPointer(const MemRegion *R)
Defines enum values for all the target-independent builtin functions.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Defines the C++ template declaration subclasses.
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
Defines the clang::Expr interface and subclasses for C++ expressions.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
Defines the clang::Preprocessor interface.
static std::string getName(const CallEvent &Call)
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
static Sema::AssignConvertType checkObjCPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
checkObjCPointerTypesForAssignment - Compares two objective-c pointer types for assignment compatibil...
static void HandleImmediateInvocations(Sema &SemaRef, Sema::ExpressionEvaluationContextRecord &Rec)
static ExprResult BuildCookedLiteralOperatorCall(Sema &S, Scope *Scope, IdentifierInfo *UDSuffix, SourceLocation UDSuffixLoc, ArrayRef< Expr * > Args, SourceLocation LitEndLoc)
BuildCookedLiteralOperatorCall - A user-defined literal was found.
static ExprResult BuildOverloadedBinOp(Sema &S, Scope *Sc, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHS, Expr *RHS)
Build an overloaded binary operator expression in the given scope.
static bool canConvertIntTyToFloatTy(Sema &S, ExprResult *Int, QualType FloatTy)
Test if a (constant) integer Int can be casted to floating point type FloatTy without losing precisio...
static bool captureInCapturedRegion(CapturedRegionScopeInfo *RSI, ValueDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool RefersToCapturedVariable, Sema::TryCaptureKind Kind, bool IsTopScope, Sema &S, bool Invalid)
Capture the given variable in the captured region.
static bool checkArithmeticOpPointerOperand(Sema &S, SourceLocation Loc, Expr *Operand)
Check the validity of an arithmetic pointer operand.
static void DiagnoseBitwisePrecedence(Sema &Self, BinaryOperatorKind Opc, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
DiagnoseBitwisePrecedence - Emit a warning when bitwise and comparison operators are mixed in a way t...
static bool isPlaceholderToRemoveAsArg(QualType type)
Is the given type a placeholder that we need to lower out immediately during argument processing?
static void diagnoseArithmeticOnNullPointer(Sema &S, SourceLocation Loc, Expr *Pointer, bool IsGNUIdiom)
Diagnose invalid arithmetic on a null pointer.
static bool CheckDeclInExpr(Sema &S, SourceLocation Loc, NamedDecl *D, bool AcceptInvalid)
Diagnoses obvious problems with the use of the given declaration as an expression.
static QualType checkConditionalObjectPointersCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Return the resulting type when the operands are both pointers.
static QualType OpenCLCheckVectorConditional(Sema &S, ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
Return the resulting type for the conditional operator in OpenCL (aka "ternary selection operator",...
static void diagnoseLogicalNotOnLHSofCheck(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Warns on !x < y, !x & y where !(x < y), !(x & y) was probably intended.
static void diagnoseArithmeticOnFunctionPointer(Sema &S, SourceLocation Loc, Expr *Pointer)
Diagnose invalid arithmetic on a function pointer.
static void diagnoseObjCLiteralComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, BinaryOperator::Opcode Opc)
static bool isCapturingReferenceToHostVarInCUDADeviceLambda(const Sema &S, VarDecl *VD)
static UnaryOperatorKind ConvertTokenKindToUnaryOpcode(tok::TokenKind Kind)
static bool isImplicitlyDefinableConstexprFunction(FunctionDecl *Func)
NonConstCaptureKind
Is the given expression (which must be 'const') a reference to a variable which was originally non-co...
static bool tryVectorConvertAndSplat(Sema &S, ExprResult *scalar, QualType scalarTy, QualType vectorEltTy, QualType vectorTy, unsigned &DiagID)
Try to convert a value of non-vector type to a vector type by converting the type to the element type...
static bool isVector(QualType QT, QualType ElementType)
This helper function returns true if QT is a vector type that has element type ElementType.
static void DiagnoseCalleeStaticArrayParam(Sema &S, ParmVarDecl *PVD)
static Expr * recoverFromMSUnqualifiedLookup(Sema &S, ASTContext &Context, DeclarationNameInfo &NameInfo, SourceLocation TemplateKWLoc, const TemplateArgumentListInfo *TemplateArgs)
In Microsoft mode, if we are inside a template class whose parent class has dependent base classes,...
static bool IsArithmeticBinaryExpr(Expr *E, BinaryOperatorKind *Opcode, Expr **RHSExprs)
IsArithmeticBinaryExpr - Returns true if E is an arithmetic binary expression, either using a built-i...
static bool isVariableCapturable(CapturingScopeInfo *CSI, ValueDecl *Var, SourceLocation Loc, const bool Diagnose, Sema &S)
static bool maybeDiagnoseAssignmentToFunction(Sema &S, QualType DstType, const Expr *SrcExpr)
static void SuggestParentheses(Sema &Self, SourceLocation Loc, const PartialDiagnostic &Note, SourceRange ParenRange)
SuggestParentheses - Emit a note with a fixit hint that wraps ParenRange in parentheses.
static void DiagnosedUnqualifiedCallsToStdFunctions(Sema &S, CallExpr *Call)
static CXXRecordDecl * LookupStdSourceLocationImpl(Sema &S, SourceLocation Loc)
static bool IgnoreCommaOperand(const Expr *E, const ASTContext &Context)
static QualType CheckRealImagOperand(Sema &S, ExprResult &V, SourceLocation Loc, bool IsReal)
static QualType checkArithmeticOrEnumeralCompare(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
static QualType CheckIndirectionOperand(Sema &S, Expr *Op, ExprValueKind &VK, SourceLocation OpLoc, bool IsAfterAmp=false)
CheckIndirectionOperand - Type check unary indirection (prefix '*').
static bool CheckAlignOfExpr(Sema &S, Expr *E, UnaryExprOrTypeTrait ExprKind)
static bool isPotentiallyConstantEvaluatedContext(Sema &SemaRef)
Are we in a context that is potentially constant evaluated per C++20 [expr.const]p12?
static void DiagnoseSelfAssignment(Sema &S, Expr *LHSExpr, Expr *RHSExpr, SourceLocation OpLoc, bool IsBuiltin)
DiagnoseSelfAssignment - Emits a warning if a value is assigned to itself.
static void diagnoseStringPlusInt(Sema &Self, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
diagnoseStringPlusInt - Emit a warning when adding an integer to a string literal.
static QualType checkConditionalPointerCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Checks compatibility between two pointers and return the resulting type.
static void DoMarkVarDeclReferenced(Sema &SemaRef, SourceLocation Loc, VarDecl *Var, Expr *E, llvm::DenseMap< const VarDecl *, int > &RefsMinusAssignments)
static bool ShouldLookupResultBeMultiVersionOverload(const LookupResult &R)
static bool checkForArray(const Expr *E)
static void DiagnoseRecursiveConstFields(Sema &S, const ValueDecl *VD, const RecordType *Ty, SourceLocation Loc, SourceRange Range, OriginalExprKind OEK, bool &DiagnosticEmitted)
static void MarkExprReferenced(Sema &SemaRef, SourceLocation Loc, Decl *D, Expr *E, bool MightBeOdrUse, llvm::DenseMap< const VarDecl *, int > &RefsMinusAssignments)
static ExprResult convertVector(Expr *E, QualType ElementType, Sema &S)
Convert vector E to a vector with the same number of elements but different element type.
static void DoMarkPotentialCapture(Sema &SemaRef, SourceLocation Loc, ValueDecl *Var, Expr *E)
static bool ExprLooksBoolean(Expr *E)
ExprLooksBoolean - Returns true if E looks boolean, i.e.
static void RecordModifiableNonNullParam(Sema &S, const Expr *Exp)
static void EvaluateAndDiagnoseImmediateInvocation(Sema &SemaRef, Sema::ImmediateInvocationCandidate Candidate)
static bool checkThreeWayNarrowingConversion(Sema &S, QualType ToType, Expr *E, QualType FromType, SourceLocation Loc)
static ExprResult convertHalfVecBinOp(Sema &S, ExprResult LHS, ExprResult RHS, BinaryOperatorKind Opc, QualType ResultTy, ExprValueKind VK, ExprObjectKind OK, bool IsCompAssign, SourceLocation OpLoc, FPOptionsOverride FPFeatures)
static QualType handleIntegerConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle integer arithmetic conversions.
static void checkDirectCallValidity(Sema &S, const Expr *Fn, FunctionDecl *Callee, MultiExprArg ArgExprs)
static void ConstructTransparentUnion(Sema &S, ASTContext &C, ExprResult &EResult, QualType UnionType, FieldDecl *Field)
Constructs a transparent union from an expression that is used to initialize the transparent union.
static QualType OpenCLConvertScalarsToVectors(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType CondTy, SourceLocation QuestionLoc)
Convert scalar operands to a vector that matches the condition in length.
static bool checkConditionalNullPointer(Sema &S, ExprResult &NullExpr, QualType PointerTy)
Return false if the NullExpr can be promoted to PointerTy, true otherwise.
static void diagnoseSubtractionOnNullPointer(Sema &S, SourceLocation Loc, Expr *Pointer, bool BothNull)
Diagnose invalid subraction on a null pointer.
static NamedDecl * getDeclFromExpr(Expr *E)
static bool checkArithmeticOnObjCPointer(Sema &S, SourceLocation opLoc, Expr *op)
Diagnose if arithmetic on the given ObjC pointer is illegal.
static bool IsInvalidCmseNSCallConversion(Sema &S, QualType FromType, QualType ToType)
static void RemoveNestedImmediateInvocation(Sema &SemaRef, Sema::ExpressionEvaluationContextRecord &Rec, SmallVector< Sema::ImmediateInvocationCandidate, 4 >::reverse_iterator It)
static void DiagnoseBitwiseOpInBitwiseOp(Sema &S, BinaryOperatorKind Opc, SourceLocation OpLoc, Expr *SubExpr)
Look for bitwise op in the left or right hand of a bitwise op with lower precedence and emit a diagno...
static void emitEmptyLookupTypoDiagnostic(const TypoCorrection &TC, Sema &SemaRef, const CXXScopeSpec &SS, DeclarationName Typo, SourceLocation TypoLoc, ArrayRef< Expr * > Args, unsigned DiagnosticID, unsigned DiagnosticSuggestID)
static QualType CheckIncrementDecrementOperand(Sema &S, Expr *Op, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation OpLoc, bool IsInc, bool IsPrefix)
CheckIncrementDecrementOperand - unlike most "Check" methods, this routine doesn't need to call Usual...
static QualType OpenCLArithmeticConversions(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
Simple conversion between integer and floating point types.
static bool checkVectorResult(Sema &S, QualType CondTy, QualType VecResTy, SourceLocation QuestionLoc)
Return false if the vector condition type and the vector result type are compatible.
static void DiagnoseDivisionSizeofPointerOrArray(Sema &S, Expr *LHS, Expr *RHS, SourceLocation Loc)
static void diagnoseTautologicalComparison(Sema &S, SourceLocation Loc, Expr *LHS, Expr *RHS, BinaryOperatorKind Opc)
Diagnose some forms of syntactically-obvious tautological comparison.
static void warnOnSizeofOnArrayDecay(Sema &S, SourceLocation Loc, QualType T, const Expr *E)
Check whether E is a pointer from a decayed array type (the decayed pointer type is equal to T) and e...
static void DiagnoseBadDivideOrRemainderValues(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsDiv)
static void ConvertUTF8ToWideString(unsigned CharByteWidth, StringRef Source, SmallString< 32 > &Target)
static TypoCorrection TryTypoCorrectionForCall(Sema &S, Expr *Fn, FunctionDecl *FDecl, ArrayRef< Expr * > Args)
static bool hasAnyExplicitStorageClass(const FunctionDecl *D)
Determine whether a FunctionDecl was ever declared with an explicit storage class.
static void DiagnoseBadShiftValues(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType LHSType)
static bool CheckVecStepTraitOperandType(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange)
static Sema::AssignConvertType checkBlockPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
checkBlockPointerTypesForAssignment - This routine determines whether two block pointer types are com...
static bool unsupportedTypeConversion(const Sema &S, QualType LHSType, QualType RHSType)
Diagnose attempts to convert between __float128, __ibm128 and long double if there is no support for ...
static void MarkVarDeclODRUsed(ValueDecl *V, SourceLocation Loc, Sema &SemaRef, const unsigned *const FunctionScopeIndexToStopAt=nullptr)
Directly mark a variable odr-used.
static void diagnoseStringPlusChar(Sema &Self, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
Emit a warning when adding a char literal to a string.
static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S)
CheckForModifiableLvalue - Verify that E is a modifiable lvalue.
static ValueDecl * getPrimaryDecl(Expr *E)
getPrimaryDecl - Helper function for CheckAddressOfOperand().
static void diagnoseUseOfInternalDeclInInlineFunction(Sema &S, const NamedDecl *D, SourceLocation Loc)
Check whether we're in an extern inline function and referring to a variable or function with interna...
static bool checkArgsForPlaceholders(Sema &S, MultiExprArg args)
Check an argument list for placeholders that we won't try to handle later.
static bool funcHasParameterSizeMangling(Sema &S, FunctionDecl *FD)
Return true if this function has a calling convention that requires mangling in the size of the param...
static bool convertPointersToCompositeType(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
Returns false if the pointers are converted to a composite type, true otherwise.
static void DiagnoseBinOpPrecedence(Sema &Self, BinaryOperatorKind Opc, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
DiagnoseBinOpPrecedence - Emit warnings for expressions with tricky precedence.
static void diagnoseAddressOfInvalidType(Sema &S, SourceLocation Loc, Expr *E, unsigned Type)
Diagnose invalid operand for address of operations.
static QualType handleComplexIntConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle conversions with GCC complex int extension.
static bool isMSPropertySubscriptExpr(Sema &S, Expr *Base)
static bool tryGCCVectorConvertAndSplat(Sema &S, ExprResult *Scalar, ExprResult *Vector)
Attempt to convert and splat Scalar into a vector whose types matches Vector following GCC conversion...
static bool handleIntegerToComplexFloatConversion(Sema &S, ExprResult &IntExpr, ExprResult &ComplexExpr, QualType IntTy, QualType ComplexTy, bool SkipCast)
Converts an integer to complex float type.
static bool captureInLambda(LambdaScopeInfo *LSI, ValueDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool RefersToCapturedVariable, const Sema::TryCaptureKind Kind, SourceLocation EllipsisLoc, const bool IsTopScope, Sema &S, bool Invalid)
Capture the given variable in the lambda.
static void DiagnoseLogicalAndInLogicalOrLHS(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
Look for '&&' in the left hand of a '||' expr.
static void CheckForNullPointerDereference(Sema &S, Expr *E)
static QualType computeConditionalNullability(QualType ResTy, bool IsBin, QualType LHSTy, QualType RHSTy, ASTContext &Ctx)
Compute the nullability of a conditional expression.
static OdrUseContext isOdrUseContext(Sema &SemaRef)
Are we within a context in which references to resolved functions or to variables result in odr-use?
static void DiagnoseConstAssignment(Sema &S, const Expr *E, SourceLocation Loc)
Emit the "read-only variable not assignable" error and print notes to give more information about why...
static Expr * BuildFloatingLiteral(Sema &S, NumericLiteralParser &Literal, QualType Ty, SourceLocation Loc)
static bool IsTypeModifiable(QualType Ty, bool IsDereference)
static bool isVariableAlreadyCapturedInScopeInfo(CapturingScopeInfo *CSI, ValueDecl *Var, bool &SubCapturesAreNested, QualType &CaptureType, QualType &DeclRefType)
static bool checkArithmeticIncompletePointerType(Sema &S, SourceLocation Loc, Expr *Operand)
Emit error if Operand is incomplete pointer type.
static bool CheckExtensionTraitOperandType(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange, UnaryExprOrTypeTrait TraitKind)
static QualType checkSizelessVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
static QualType checkArithmeticOrEnumeralThreeWayCompare(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
static void DiagnoseConditionalPrecedence(Sema &Self, SourceLocation OpLoc, Expr *Condition, Expr *LHSExpr, Expr *RHSExpr)
DiagnoseConditionalPrecedence - Emit a warning when a conditional operator and binary operator are mi...
static ExprResult diagnoseUnknownAnyExpr(Sema &S, Expr *E)
static SourceLocation getUDSuffixLoc(Sema &S, SourceLocation TokLoc, unsigned Offset)
getUDSuffixLoc - Create a SourceLocation for a ud-suffix, given the location of the token and the off...
static bool checkBlockType(Sema &S, const Expr *E)
Return true if the Expr is block type.
static bool captureInBlock(BlockScopeInfo *BSI, ValueDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool Nested, Sema &S, bool Invalid)
static QualType handleFloatConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle arithmethic conversion with floating point types.
static void diagnoseArithmeticOnVoidPointer(Sema &S, SourceLocation Loc, Expr *Pointer)
Diagnose invalid arithmetic on a void pointer.
static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Return the resulting type when a vector is shifted by a scalar or vector shift amount.
static void diagnoseUncapturableValueReferenceOrBinding(Sema &S, SourceLocation loc, ValueDecl *var)
ExprResult PerformCastFn(Sema &S, Expr *operand, QualType toType)
static void checkArithmeticNull(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompare)
static bool IsReadonlyMessage(Expr *E, Sema &S)
static void buildLambdaCaptureFixit(Sema &Sema, LambdaScopeInfo *LSI, ValueDecl *Var)
Create up to 4 fix-its for explicit reference and value capture of Var or default capture.
static void tryImplicitlyCaptureThisIfImplicitMemberFunctionAccessWithDependentArgs(Sema &S, const UnresolvedMemberExpr *const UME, SourceLocation CallLoc)
static Sema::AssignConvertType checkPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType, SourceLocation Loc)
static void DiagnoseLogicalAndInLogicalOrRHS(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
Look for '&&' in the right hand of a '||' expr.
static bool checkCondition(Sema &S, Expr *Cond, SourceLocation QuestionLoc)
Return false if the condition expression is valid, true otherwise.
static QualType getDependentArraySubscriptType(Expr *LHS, Expr *RHS, const ASTContext &Ctx)
static void checkEnumArithmeticConversions(Sema &S, Expr *LHS, Expr *RHS, SourceLocation Loc, Sema::ArithConvKind ACK)
Check that the usual arithmetic conversions can be performed on this pair of expressions that might b...
static void diagnosePointerIncompatibility(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Emit error when two pointers are incompatible.
static bool enclosingClassIsRelatedToClassInWhichMembersWereFound(const UnresolvedMemberExpr *const UME, Sema &S)
static unsigned GetFixedPointRank(QualType Ty)
Return the rank of a given fixed point or integer type.
static bool CheckObjCTraitOperandConstraints(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange, UnaryExprOrTypeTrait TraitKind)
static void diagnoseArithmeticOnTwoFunctionPointers(Sema &S, SourceLocation Loc, Expr *LHS, Expr *RHS)
Diagnose invalid arithmetic on two function pointers.
static bool checkPointerIntegerMismatch(Sema &S, ExprResult &Int, Expr *PointerExpr, SourceLocation Loc, bool IsIntFirstExpr)
Return false if the first expression is not an integer and the second expression is not a pointer,...
static ImplicitConversionKind castKindToImplicitConversionKind(CastKind CK)
static void diagnoseXorMisusedAsPow(Sema &S, const ExprResult &XorLHS, const ExprResult &XorRHS, const SourceLocation Loc)
static bool checkOpenCLConditionVector(Sema &S, Expr *Cond, SourceLocation QuestionLoc)
Return false if this is a valid OpenCL condition vector.
static bool IsArithmeticOp(BinaryOperatorKind Opc)
static std::pair< ExprResult, ExprResult > CorrectDelayedTyposInBinOp(Sema &S, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
static void checkObjCPointerIntrospection(Sema &S, ExprResult &L, ExprResult &R, SourceLocation OpLoc)
Check if a bitwise-& is performed on an Objective-C pointer.
static void DiagnoseDirectIsaAccess(Sema &S, const ObjCIvarRefExpr *OIRE, SourceLocation AssignLoc, const Expr *RHS)
static ExprResult rebuildUnknownAnyFunction(Sema &S, Expr *fn)
Given a function expression of unknown-any type, try to rebuild it to have a function type.
static QualType handleIntToFloatConversion(Sema &S, ExprResult &FloatExpr, ExprResult &IntExpr, QualType FloatTy, QualType IntTy, bool ConvertFloat, bool ConvertInt)
Handle arithmetic conversion from integer to float.
static bool hasIsEqualMethod(Sema &S, const Expr *LHS, const Expr *RHS)
static QualType handleComplexFloatConversion(Sema &S, ExprResult &Shorter, QualType ShorterType, QualType LongerType, bool PromotePrecision)
static FunctionDecl * rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context, FunctionDecl *FDecl, MultiExprArg ArgExprs)
If a builtin function has a pointer argument with no explicit address space, then it should be able t...
static void DoMarkBindingDeclReferenced(Sema &SemaRef, SourceLocation Loc, BindingDecl *BD, Expr *E)
static void DiagnoseUnusedOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc)
static QualType handleFixedPointConversion(Sema &S, QualType LHSTy, QualType RHSTy)
handleFixedPointConversion - Fixed point operations between fixed point types and integers or other f...
static QualType handleComplexConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle arithmetic conversion with complex types.
static QualType CheckCommaOperands(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
static bool canCaptureVariableByCopy(ValueDecl *Var, const ASTContext &Context)
static void diagnoseArithmeticOnTwoVoidPointers(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Diagnose invalid arithmetic on two void pointers.
static void diagnoseDistinctPointerComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, bool IsError)
Diagnose bad pointer comparisons.
static bool needsConversionOfHalfVec(bool OpRequiresConversion, ASTContext &Ctx, Expr *E0, Expr *E1=nullptr)
Returns true if conversion between vectors of halfs and vectors of floats is needed.
static bool isObjCObjectLiteral(ExprResult &E)
static NonConstCaptureKind isReferenceToNonConstCapture(Sema &S, Expr *E)
static QualType checkConditionalBlockPointerCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Return the resulting type when the operands are both block pointers.
static void DiagnoseShiftCompare(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
static void DiagnoseAdditionInShift(Sema &S, SourceLocation OpLoc, Expr *SubExpr, StringRef Shift)
static void diagnoseFunctionPointerToVoidComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, bool IsError)
static void EmitDiagnosticForLogicalAndInLogicalOr(Sema &Self, SourceLocation OpLoc, BinaryOperator *Bop)
It accepts a '&&' expr that is inside a '||' one.
static void captureVariablyModifiedType(ASTContext &Context, QualType T, CapturingScopeInfo *CSI)
static bool canConvertIntToOtherIntTy(Sema &S, ExprResult *Int, QualType OtherIntTy)
Test if a (constant) integer Int can be casted to another integer type IntTy without losing precision...
static DeclContext * getParentOfCapturingContextOrNull(DeclContext *DC, ValueDecl *Var, SourceLocation Loc, const bool Diagnose, Sema &S)
static bool isOverflowingIntegerType(ASTContext &Ctx, QualType T)
static void CheckIdentityFieldAssignment(Expr *LHSExpr, Expr *RHSExpr, SourceLocation Loc, Sema &Sema)
static bool isLegalBoolVectorBinaryOp(BinaryOperatorKind Opc)
static ExprResult rebuildPotentialResultsAsNonOdrUsed(Sema &S, Expr *E, NonOdrUseReason NOUR)
Walk the set of potential results of an expression and mark them all as non-odr-uses if they satisfy ...
static void CheckCompleteParameterTypesForMangler(Sema &S, FunctionDecl *FD, SourceLocation Loc)
Require that all of the parameter types of function be complete.
static bool isScopedEnumerationType(QualType T)
static bool checkArithmeticBinOpPointerOperands(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Check the validity of a binary arithmetic operation w.r.t.
static bool breakDownVectorType(QualType type, uint64_t &len, QualType &eltType)
static bool isInvalid(LocType Loc, bool *Invalid)
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
@ Open
The standard open() call: int open(const char *path, int oflag, ...);.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
std::string getAsString(const ASTContext &Ctx, QualType Ty) const
virtual void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D)
Invoked when a function is implicitly instantiated.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
BuiltinVectorTypeInfo getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const
Returns the element type, element count and number of vectors (in case of tuple) for a builtin vector...
TranslationUnitDecl * getTranslationUnitDecl() const
const ConstantArrayType * getAsConstantArrayType(QualType T) const
bool areLaxCompatibleSveTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible SVE vector types, false otherwise.
CanQualType ARCUnbridgedCastTy
unsigned getIntWidth(QualType T) const
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType) const
bool areCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an RISC-V vector builtin type and a VectorType that is a fixed-len...
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
QualType areCommonBaseCompatible(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
bool ObjCQualifiedIdTypesAreCompatible(const ObjCObjectPointerType *LHS, const ObjCObjectPointerType *RHS, bool ForCompare)
ObjCQualifiedIdTypesAreCompatible - We know that one of lhs/rhs is an ObjCQualifiedIDType.
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
QualType getBuiltinVaListType() const
Retrieve the type of the __builtin_va_list type.
DeclarationNameTable DeclarationNames
int getIntegerTypeOrder(QualType LHS, QualType RHS) const
Return the highest ranked integer type, see C99 6.3.1.8p1.
QualType getRecordType(const RecordDecl *Decl) const
QualType getScalableVectorType(QualType EltTy, unsigned NumElts, unsigned NumFields=1) const
Return the unique reference to a scalable vector type of the specified element type and scalable numb...
QualType getBuiltinMSVaListType() const
Retrieve the type of the __builtin_ms_va_list type.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
QualType getCorrespondingSignedFixedPointType(QualType Ty) const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
CanQualType OMPArrayShapingTy
QualType getObjCSelRedefinitionType() const
Retrieve the type that 'SEL' has been defined to, which may be different from the built-in 'SEL' if '...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
QualType getReferenceQualifiedType(const Expr *e) const
getReferenceQualifiedType - Given an expr, will return the type for that expression,...
bool isObjCSelType(QualType T) const
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
CanQualType OMPIteratorTy
Builtin::Context & BuiltinInfo
const LangOptions & getLangOpts() const
bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible RISC-V vector types as defined by -flax-vect...
TypedefDecl * getBOOLDecl() const
Retrieve declaration of 'BOOL' typedef.
bool typesAreBlockPointerCompatible(QualType, QualType)
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
void setBOOLDecl(TypedefDecl *TD)
Save declaration of 'BOOL' typedef.
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i....
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth,...
CanQualType UnsignedLongTy
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
QualType getStringLiteralArrayType(QualType EltTy, unsigned Length) const
Return a type for a constant array for a string literal of the specified element type and length.
QualType getCorrespondingSaturatedType(QualType Ty) const
QualType getBOOLType() const
type of 'BOOL' type.
CanQualType BoundMemberTy
QualType removeAddrSpaceQualType(QualType T) const
Remove any existing address space on the type and returns the type with qualifiers intact (or that's ...
llvm::DenseSet< const VarDecl * > CUDADeviceVarODRUsedByHost
Keep track of CUDA/HIP device-side variables ODR-used by host code.
CanQualType PseudoObjectTy
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorType::VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
bool areComparableObjCPointerTypes(QualType LHS, QualType RHS)
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
CanQualType ObjCBuiltinBoolTy
llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false, bool IsConditionalOperator=false)
static bool isObjCNSObjectType(QualType Ty)
Return true if this is an NSObject object with its NSObject attribute set.
QualType getObjCIdType() const
Represents the Objective-CC id type.
llvm::DenseSet< const ValueDecl * > CUDAExternalDeviceDeclODRUsedByHost
Keep track of CUDA/HIP external kernels or device variables ODR-used by host code.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
CanQualType UnsignedCharTy
CanQualType UnsignedIntTy
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
QualType getObjCClassRedefinitionType() const
Retrieve the type that Class has been defined to, which may be different from the built-in Class if C...
CanQualType UnsignedLongLongTy
QualType getCommonSugaredType(QualType X, QualType Y, bool Unqualified=false)
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getObjCIdRedefinitionType() const
Retrieve the type that id has been defined to, which may be different from the built-in id if id has ...
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
llvm::APFixedPoint getFixedPointMax(QualType Ty) const
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type.
bool areCompatibleSveTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an SVE builtin and a VectorType that is a fixed-length representat...
bool hasDirectOwnershipQualifier(QualType Ty) const
Return true if the type has been explicitly qualified with ObjC ownership.
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec)
Return true if the given vector types are of the same unqualified type or if they are equivalent to t...
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
const TargetInfo & getTargetInfo() const
CanQualType IncompleteMatrixIdxTy
std::optional< CharUnits > getTypeSizeInCharsIfKnown(QualType Ty) const
QualType getCorrespondingUnsignedType(QualType T) const
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
QualType getCorrespondingSignedType(QualType T) const
unsigned getTargetAddressSpace(LangAS AS) const
QualType getWideCharType() const
Return the type of wide characters.
bool isPromotableIntegerType(QualType T) const
More type predicates useful for type checking/promotion.
CanQualType getSignedSizeType() const
Return the unique signed counterpart of the integer type corresponding to size_t.
QualType getLogicalOperationType() const
The result type of logical operations, '<', '>', '!=', etc.
unsigned char getFixedPointScale(QualType Ty) const
QualType adjustStringLiteralBaseType(QualType StrLTy) const
bool hasCvrSimilarType(QualType T1, QualType T2)
Determine if two types are similar, ignoring only CVR qualifiers.
bool isDependenceAllowed() const
QualType getConstantMatrixType(QualType ElementType, unsigned NumRows, unsigned NumColumns) const
Return the unique reference to the matrix type of the specified element type and size.
QualType isPromotableBitField(Expr *E) const
Whether this is a promotable bitfield reference according to C99 6.3.1.1p2, bullet 2 (and GCC extensi...
bool isSentinelNullExpr(const Expr *E)
CanQualType OMPArraySectionTy
uint64_t getCharWidth() const
Return the size of the character type, in bits.
QualType getBitIntType(bool Unsigned, unsigned NumBits) const
Return a bit-precise integer type with the specified signedness and bit count.
AddrLabelExpr - The GNU address of label extension, representing &&label.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
SourceLocation getExprLoc() const LLVM_READONLY
Wrapper for source info for arrays.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
ArraySizeModifier getSizeModifier() const
QualType getElementType() const
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Attr - This represents one attribute.
One specifier in an @available expression.
StringRef getPlatform() const
VersionTuple getVersion() const
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
A builtin binary operation expression such as "x + y" or "x <= y".
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
static bool isComparisonOp(Opcode Opc)
bool isComparisonOp() const
StringRef getOpcodeStr() const
bool isRelationalOp() const
SourceLocation getOperatorLoc() const
bool isCompoundAssignmentOp() const
bool isMultiplicativeOp() const
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to,...
bool isEqualityOp() const
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
bool isAdditiveOp() const
static bool isNullPointerArithmeticExtension(ASTContext &Ctx, Opcode Opc, const Expr *LHS, const Expr *RHS)
Return true if a binary operator using the specified opcode and operands would match the 'p = (i8*)nu...
bool isAssignmentOp() const
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
static bool isBitwiseOp(Opcode Opc)
A binding in a decomposition declaration.
A class which contains all the information about a particular captured value.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
void setParams(ArrayRef< ParmVarDecl * > NewParamInfo)
void setSignatureAsWritten(TypeSourceInfo *Sig)
void setBlockMissingReturnType(bool val=true)
void setIsVariadic(bool value)
SourceLocation getCaretLocation() const
void setBody(CompoundStmt *B)
ArrayRef< ParmVarDecl * > parameters() const
void setCaptures(ASTContext &Context, ArrayRef< Capture > Captures, bool CapturesCXXThis)
static BlockDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
This class is used for builtin types like 'int'.
bool hasPtrArgsOrResult(unsigned ID) const
Determines whether this builtin has a result or any arguments which are pointer types.
llvm::StringRef getName(unsigned ID) const
Return the identifier name for the specified builtin, e.g.
bool hasCustomTypechecking(unsigned ID) const
Determines whether this builtin has custom typechecking.
bool isInStdNamespace(unsigned ID) const
Determines whether this builtin is a C++ standard library function that lives in (possibly-versioned)...
bool isDirectlyAddressable(unsigned ID) const
Determines whether this builtin can have its address taken with no special action required.
static CUDAKernelCallExpr * Create(const ASTContext &Ctx, Expr *Fn, CallExpr *Config, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RP, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0)
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
Represents a C++ constructor within a class.
Represents a C++ conversion function within a class.
bool isLambdaToBlockPointerConversion() const
Determine whether this conversion function is a conversion from a lambda closure type to a block poin...
Represents a C++ base or member initializer.
A default argument (C++ [dcl.fct.default]).
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr, DeclContext *UsedContext)
A use of a default initializer in a constructor or in aggregate initialization.
static CXXDefaultInitExpr * Create(const ASTContext &Ctx, SourceLocation Loc, FieldDecl *Field, DeclContext *UsedContext, Expr *RewrittenInitExpr)
Field is the non-static data member whose default initializer is used by this expression.
Expr * getExpr()
Get the initialization expression that will be used.
static CXXDependentScopeMemberExpr * Create(const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
Represents a C++ destructor within a class.
Represents a static or instance method of a struct/union/class.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
CXXMethodDecl * getDevirtualizedMethod(const Expr *Base, bool IsAppleKext)
If it's possible to devirtualize a call to this method, return the called function.
A call to an overloaded operator written using operator syntax.
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
SourceRange getSourceRange() const
Represents a C++ struct/union/class.
bool isStandardLayout() const
Determine whether this class is standard-layout per C++ [class]p7.
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation.
unsigned getNumBases() const
Retrieves the number of base classes of this class.
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
Represents a C++ nested-name-specifier or a global scope specifier.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
SourceRange getRange() const
SourceLocation getBeginLoc() const
bool isSet() const
Deprecated.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool isEmpty() const
No scope specifier.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Represents the this expression in C++.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
void setArg(unsigned Arg, Expr *ArgExpr)
setArg - Set the specified argument.
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
void computeDependence()
Compute and set dependence bits.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Expr ** getArgs()
Retrieve the call arguments.
void setNumArgsUnsafe(unsigned NewNumArgs)
Bluntly set a new number of arguments without doing any checks whatsoever.
void shrinkNumArgs(unsigned NewNumArgs)
Reduce the number of arguments in this call expression.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
QualType withConst() const
Retrieves a version of this type with const applied.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
CastKind getCastKind() const
const char * getCastKindName() const
CharLiteralParser - Perform interpretation and semantic analysis of a character literal.
Represents a character-granular source range.
static CharSourceRange getCharRange(SourceRange R)
static CharSourceRange getTokenRange(SourceRange R)
CharUnits - This is an opaque type for sizes expressed in character units.
bool isZero() const
isZero - Test whether the quantity equals zero.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
unsigned getValue() const
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Complex values, per C99 6.2.5p11.
QualType getElementType() const
static CompoundAssignOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures, QualType CompLHSType=QualType(), QualType CompResultType=QualType())
CompoundLiteralExpr - [C99 6.5.2.5].
CompoundStmt - This represents a group of statements like { stmt stmt }.
Stmt * getStmtExprResult()
ConditionalOperator - The ?: ternary operator.
Represents the canonical version of C arrays with a specified constant size.
const llvm::APInt & getSize() const
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
void MoveIntoResult(APValue &Value, const ASTContext &Context)
SourceLocation getBeginLoc() const LLVM_READONLY
static ResultStorageKind getStorageKind(const APValue &Value)
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
bool isImmediateInvocation() const
Represents a concrete matrix type with constant number of rows and columns.
unsigned getNumColumns() const
Returns the number of columns in the matrix.
unsigned getNumRows() const
Returns the number of rows in the matrix.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
void setTypoName(IdentifierInfo *II)
void setTypoNNS(NestedNameSpecifier *NNS)
Wrapper for source info for pointers decayed from arrays and functions.
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
The results of name lookup within a DeclContext.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
const BlockDecl * getInnermostBlockDecl() const
Return this DeclContext if it is a BlockDecl.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void addDecl(Decl *D)
Add the declaration D into this context.
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
RecordDecl * getOuterLexicalRecordContext()
Retrieve the outermost lexically enclosing record context.
bool isFunctionOrMethod() const
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
A reference to a declared variable, function, enum, etc.
NamedDecl * getFoundDecl()
Get the NamedDecl through which this reference occurred.
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list.
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
void setDecl(ValueDecl *NewD)
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments (if present) into the given structure.
SourceLocation getBeginLoc() const LLVM_READONLY
DeclarationNameInfo getNameInfo() const
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr, NonOdrUseReason NOUR=NOUR_None)
bool hasQualifier() const
Determine whether this declaration reference was preceded by a C++ nested-name-specifier,...
NestedNameSpecifierLoc getQualifierLoc() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name,...
SourceLocation getLocation() const
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
Decl - This represents one declaration (or definition), e.g.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple(), StringRef *RealizedPlatform=nullptr) const
Determine the availability of the given declaration.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
bool isInvalidDecl() const
SourceLocation getLocation() const
void setReferenced(bool R=true)
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
bool isDefinedOutsideFunctionOrMethod() const
isDefinedOutsideFunctionOrMethod - This predicate returns true if this scoped decl is defined outside...
DeclContext * getDeclContext()
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
The name of a declaration.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
bool isDependentName() const
Determines whether the name itself is dependent, e.g., because it involves a C++ type that is itself ...
std::string getAsString() const
Retrieve the human-readable string for this name.
@ CXXConversionFunctionName
bool isIdentifier() const
Predicate functions for querying what type of name this is.
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
TypeSourceInfo * getTypeSourceInfo() const
Information about one declarator, including the parsed type information and the identifier.
DeclaratorContext getContext() const
SourceLocation getBeginLoc() const LLVM_READONLY
IdentifierInfo * getIdentifier() const
bool isInvalidType() const
static DependentScopeDeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
bool getSuppressSystemWarnings() const
void setElaboratedKeywordLoc(SourceLocation Loc)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
RAII object that enters a new expression evaluation context.
ExplicitCastExpr - An explicit cast written in the source code.
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
static ExprWithCleanups * Create(const ASTContext &C, EmptyShell empty, unsigned numObjects)
This represents one expression.
bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects, bool InConstantContext=false) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer,...
Expr * IgnoreParenNoopCasts(const ASTContext &Ctx) LLVM_READONLY
Skip past any parentheses and casts which do not change the value (including ptr->int casts of the sa...
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
isModifiableLvalueResult isModifiableLvalue(ASTContext &Ctx, SourceLocation *Loc=nullptr) const
isModifiableLvalue - C99 6.3.2.1: an lvalue that does not have array type, does not have an incomplet...
static QualType findBoundMemberType(const Expr *expr)
Given an expression of bound-member type, find the type of the member.
llvm::APSInt EvaluateKnownConstIntCheckOverflow(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
LValueClassification ClassifyLValue(ASTContext &Ctx) const
Reasons why an expression might not be an l-value.
bool isValueDependent() const
Determines whether the value of this expression depends on.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates).
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Expr * IgnoreConversionOperatorSingleStep() LLVM_READONLY
Skip conversion operators.
bool containsErrors() const
Whether this expression contains subexpressions which had errors, e.g.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language.
static bool hasAnyTypeDependentArguments(ArrayRef< Expr * > Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
@ NPC_ValueDependentIsNull
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
@ NPC_NeverValueDependent
Specifies that the expression should never be value-dependent.
@ NPC_ValueDependentIsNotNull
Specifies that a value-dependent expression should be considered to never be a null pointer constant.
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
bool EvaluateAsConstantExpr(EvalResult &Result, const ASTContext &Ctx, ConstantExprKind Kind=ConstantExprKind::Normal) const
Evaluate an expression that is required to be a constant expression.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
bool isIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr) const
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant().
@ NPCK_ZeroExpression
Expression is a Null pointer constant built from a zero integer expression that is not a simple,...
@ NPCK_ZeroLiteral
Expression is a Null pointer constant built from a literal zero.
@ NPCK_CXX11_nullptr
Expression is a C++11 nullptr.
@ NPCK_NotNull
Expression is not a Null pointer constant.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant.
void setValueKind(ExprValueKind Cat)
setValueKind - Set the value kind produced by this expression.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
static bool isSameComparisonOperand(const Expr *E1, const Expr *E2)
Checks that the two Expr's will refer to the same value as a comparison operand.
void setObjectKind(ExprObjectKind Cat)
setObjectKind - Set the object kind produced by this expression.
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
@ MLV_DuplicateVectorComponents
@ MLV_InvalidMessageExpression
@ MLV_ConstQualifiedField
@ MLV_SubObjCPropertySetting
bool isOrdinaryOrBitFieldObject() const
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
bool isKnownToHaveBooleanValue(bool Semantic=true) const
isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or...
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
ExtVectorType - Extended vector type.
Represents difference between two FPOptions values.
bool isFPConstrained() const
Represents a member of a struct/union/class.
bool isBitField() const
Determines whether this field is a bitfield.
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
static FixedPointLiteral * CreateFromRawInt(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l, unsigned Scale)
static FloatingLiteral * Create(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L)
FullExpr - Represents a "full-expression" node.
const Expr * getSubExpr() const
bool ValidateCandidate(const TypoCorrection &candidate) override
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
Represents a function declaration or definition.
void setInstantiationIsPending(bool IC)
State that the instantiation of this function is pending.
const ParmVarDecl * getParamDecl(unsigned i) const
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
bool isImmediateFunction() const
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
SourceLocation getPointOfInstantiation() const
Retrieve the (first) point of instantiation of a function template specialization or a member of a cl...
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
QualType getReturnType() const
ArrayRef< ParmVarDecl * > parameters() const
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization,...
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isDeleted() const
Whether this function has been deleted.
TemplateSpecializationKind getTemplateSpecializationKindForInstantiation() const
Determine the kind of template specialization this function represents for the purpose of template in...
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
bool isImplicitlyInstantiable() const
Determines whether this function is a function template specialization or a member of a class templat...
bool isExternC() const
Determines whether this function is a function with external, C linkage.
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin=false, bool isInlineSpecified=false, bool hasWrittenPrototype=true, ConstexprSpecKind ConstexprKind=ConstexprSpecKind::Unspecified, Expr *TrailingRequiresClause=nullptr)
bool isDefaulted() const
Whether this function is defaulted.
bool isOverloadedOperator() const
Whether this function declaration represents an C++ overloaded operator, e.g., "operator+".
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
Determine what kind of template instantiation this function represents.
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration.
size_t param_size() const
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
SourceRange getParametersSourceRange() const
Attempt to compute an informative source range covering the function parameters, including the ellips...
bool isDefined(const FunctionDecl *&Definition, bool CheckForPendingFriendDefinition=false) const
Returns true if the function has a definition that does not need to be instantiated.
QualType getCallResultType() const
Determine the type of an expression that calls this function.
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
SourceLocation getParameterPackLocation() const
Get the location of the parameter pack.
Represents a prototype with parameter type info, e.g.
ExtParameterInfo getExtParameterInfo(unsigned I) const
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
bool isParamConsumed(unsigned I) const
unsigned getNumParams() const
QualType getParamType(unsigned i) const
bool isVariadic() const
Whether this function prototype is variadic.
ExtProtoInfo getExtProtoInfo() const
ArrayRef< QualType > getParamTypes() const
ArrayRef< QualType > param_types() const
Declaration of a template function.
unsigned getNumParams() const
ParmVarDecl * getParam(unsigned i) const
SourceLocation getLocalRangeEnd() const
TypeLoc getReturnLoc() const
SourceLocation getLocalRangeBegin() const
A class which abstracts out some details necessary for making a call.
bool getCmseNSCall() const
ExtInfo withNoReturn(bool noReturn) const
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
bool getNoReturnAttr() const
Determine whether this function type includes the GNU noreturn attribute.
QualType getReturnType() const
bool getCmseNSCallAttr() const
QualType getCallResultType(const ASTContext &Context) const
Determine the type of an expression that calls a function of this type.
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
static GenericSelectionExpr * Create(const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > AssocTypes, ArrayRef< Expr * > AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
Create a non-result-dependent generic selection expression accepting an expression predicate.
One of these records is kept for each identifier that is lexed.
tok::TokenKind getTokenID() const
If this is a source-language token (e.g.
bool isEditorPlaceholder() const
Return true if this identifier is an editor placeholder.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
Represents a field injected from an anonymous union/struct into the parent scope.
Describes an C or C++ initializer list.
Describes the kind of initialization being performed, along with location information for tokens rela...
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
static InitializationKind CreateCStyleCast(SourceLocation StartLoc, SourceRange TypeRange, bool InitList)
Create a direct initialization for a C-style cast.
Describes the sequence of initializations required to initialize a given object or reference with a s...
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence.
Describes an entity that is being initialized.
void setParameterCFAudited()
static InitializedEntity InitializeStmtExprResult(SourceLocation ReturnLoc, QualType Type)
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
static InitializedEntity InitializeBlock(SourceLocation BlockVarLoc, QualType Type)
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
static InitializedEntity InitializeCompoundLiteralInit(TypeSourceInfo *TSI)
Create the entity for a compound literal initializer.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Represents the declaration of a label.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
clang::ObjCRuntime ObjCRuntime
bool isSubscriptPointerArithmetic() const
bool isSignedOverflowDefined() const
@ None
Permit no implicit vector bitcasts.
@ Integer
Permit vector bitcasts between integer vectors with different numbers of elements but the same total ...
@ All
Permit vector bitcasts between all vectors with the same total bit-width.
FPEvalMethodKind
Possible float expression evaluation method choices.
@ FEM_UnsetOnCommandLine
Used only for FE option processing; this is only used to indicate that the user did not specify an ex...
@ FEM_Source
Use the declared type for fp arithmetic.
@ FEM_Double
Use the type double for fp arithmetic.
@ FEM_Extended
Use extended type for fp arithmetic.
unsigned getOpenCLCompatibleVersion() const
Return the OpenCL version that kernel language is compatible with.
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
static SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart, unsigned Characters, const SourceManager &SM, const LangOptions &LangOpts)
AdvanceToTokenCharacter - If the current SourceLocation specifies a location at the start of a token,...
Represents the results of name lookup.
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
bool isUnresolvableResult() const
DeclClass * getAsSingle() const
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
void setLookupName(DeclarationName Name)
Sets the name to look up.
bool empty() const
Return true if no decls were found.
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
bool isOverloadedResult() const
Determines if the results are overloaded.
SourceLocation getNameLoc() const
Gets the location of the identifier.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
CXXRecordDecl * getNamingClass() const
Returns the 'naming class' for this lookup, i.e.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
void setNamingClass(CXXRecordDecl *Record)
Sets the 'naming class' for this lookup.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
LookupResultKind getResultKind() const
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
DeclarationName getLookupName() const
Gets the name to look up.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
MS property subscript expression.
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
virtual unsigned getManglingNumber(const CXXMethodDecl *CallOperator)=0
Retrieve the mangling number of a new lambda expression with the given call operator within this cont...
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
Represents a matrix type, as defined in the Matrix Types clang extensions.
QualType getElementType() const
Returns type of the elements being stored in the matrix.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
SourceLocation getMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of 'F'.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
static MemberExpr * Create(const ASTContext &C, Expr *Base, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *MemberDecl, DeclAccessPair FoundDecl, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs, QualType T, ExprValueKind VK, ExprObjectKind OK, NonOdrUseReason NOUR)
bool performsVirtualDispatch(const LangOptions &LO) const
Returns true if virtual dispatch is performed.
SourceLocation getBeginLoc() const LLVM_READONLY
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
std::string getQualifiedNameAsString() const
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
bool isExternallyVisible() const
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
Represent a C++ namespace.
A C++ nested-name-specifier augmented with source location information.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
NumericLiteralParser - This performs strict semantic analysis of the content of a ppnumber,...
OpenMP 5.0 [2.1.5, Array Sections].
static QualType getBaseOriginalType(const Expr *Base)
Return original type of the base expression for array section.
static OMPArrayShapingExpr * Create(const ASTContext &Context, QualType T, Expr *Op, SourceLocation L, SourceLocation R, ArrayRef< Expr * > Dims, ArrayRef< SourceRange > BracketRanges)
static OMPIteratorExpr * Create(const ASTContext &Context, QualType T, SourceLocation IteratorKwLoc, SourceLocation L, SourceLocation R, ArrayRef< IteratorDefinition > Data, ArrayRef< OMPIteratorHelperData > Helpers)
A runtime availability query.
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Represents an ObjC class declaration.
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
bool hasDefinition() const
Determine whether this class has been defined.
ivar_iterator ivar_begin() const
ObjCInterfaceDecl * getSuperClass() const
Represents typeof(type), a C2x feature and GCC extension, or `typeof_unqual(type),...
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
ObjCIvarDecl - Represents an ObjC instance variable.
AccessControl getAccessControl() const
QualType getUsageType(QualType objectType) const
Retrieve the type of this instance variable when viewed as a member of a specific object type.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getLocation() const
SourceLocation getOpLoc() const
SourceLocation getEndLoc() const LLVM_READONLY
const Expr * getBase() const
An expression that sends a message to the given Objective-C object or class.
const ObjCMethodDecl * getMethodDecl() const
ObjCMethodDecl - Represents an instance or class method declaration.
ImplicitParamDecl * getSelfDecl() const
bool isInstanceMethod() const
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
bool isClassMethod() const
ObjCInterfaceDecl * getClassInterface()
Represents a pointer to an Objective C object.
bool isObjCQualifiedIdType() const
True if this is equivalent to 'id.
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
Represents one property declaration in an Objective-C interface.
Represents an Objective-C protocol declaration.
bool allowsSizeofAlignof() const
Does this runtime allow sizeof or alignof on object types?
bool allowsPointerArithmetic() const
Does this runtime allow pointer arithmetic on objects?
static OffsetOfExpr * Create(const ASTContext &C, QualType type, SourceLocation OperatorLoc, TypeSourceInfo *tsi, ArrayRef< OffsetOfNode > comps, ArrayRef< Expr * > exprs, SourceLocation RParenLoc)
Helper class for OffsetOfExpr.
void * getAsOpaquePtr() const
static OpaquePtr getFromOpaquePtr(void *P)
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
@ CSK_Normal
Normal lookup.
SmallVectorImpl< OverloadCandidate >::iterator iterator
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
ParenExpr - This represents a parethesized expression, e.g.
SourceLocation getBeginLoc() const LLVM_READONLY
const Expr * getSubExpr() const
Expr * getExpr(unsigned Init)
static ParenListExpr * Create(const ASTContext &Ctx, SourceLocation LParenLoc, ArrayRef< Expr * > Exprs, SourceLocation RParenLoc)
Create a paren list.
unsigned getNumExprs() const
Return the number of expressions in this paren list.
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
Represents a parameter to a function.
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
static std::string ComputeName(IdentKind IK, const Decl *CurrentDecl)
static PredefinedExpr * Create(const ASTContext &Ctx, SourceLocation L, QualType FNTy, IdentKind IK, bool IsTransparent, StringLiteral *SL)
Create a PredefinedExpr.
SourceLocation getLastFPEvalPragmaLocation() const
LangOptions::FPEvalMethodKind getCurrentFPEvalMethod() const
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
SourceManager & getSourceManager() const
bool isMacroDefined(StringRef Id)
const TargetInfo & getTargetInfo() const
char getSpellingOfSingleCharacterNumericConstant(const Token &Tok, bool *Invalid=nullptr) const
Given a Token Tok that is a numeric constant with length 1, return the character.
StringRef getSpelling(SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const
Return the 'spelling' of the token at the given location; does not go up to the spelling location or ...
bool isCodeCompletionEnabled() const
Determine if we are performing code completion.
IdentifierTable & getIdentifierTable()
const LangOptions & getLangOpts() const
DiagnosticsEngine & getDiagnostics() const
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) const
Forwarding function for diagnostics.
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
bool hasNonTrivialToPrimitiveCopyCUnion() const
Check if this is or contains a C union that is non-trivial to copy, which is a union that has a membe...
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const
QualType withConst() const
void addConst()
Add the const type qualifier to this QualType.
bool isAtLeastAsQualifiedAs(QualType Other) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
bool hasNonTrivialToPrimitiveDestructCUnion() const
Check if this is or contains a C union that is non-trivial to destruct, which is a union that has a m...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool isAddressSpaceOverlapping(QualType T) const
Returns true if address space qualifiers overlap with T address space qualifiers.
bool isCXX98PODType(const ASTContext &Context) const
Return true if this is a POD type according to the rules of the C++98 standard, regardless of the cur...
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
bool isWebAssemblyReferenceType() const
Returns true if it is a WebAssembly Reference Type.
QualType withCVRQualifiers(unsigned CVR) const
bool isCForbiddenLValueType() const
Determine whether expressions of the given type are forbidden from being lvalues in C.
bool isConstQualified() const
Determine whether this type is const-qualified.
bool hasAddressSpace() const
Check if this type has any address space qualifier.
QualType getAtomicUnqualifiedType() const
Remove all qualifiers including _Atomic.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
Check if this is or contains a C union that is non-trivial to default-initialize, which is a union th...
The collection of all-type qualifiers we support.
unsigned getCVRQualifiers() const
void removeCVRQualifiers(unsigned mask)
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
void removeObjCLifetime()
void removeAddressSpace()
void setAddressSpace(LangAS space)
static bool isAddressSpaceSupersetOf(LangAS A, LangAS B)
Returns true if address space A is equal to or a superset of B.
ObjCLifetime getObjCLifetime() const
Qualifiers withoutObjCLifetime() const
Qualifiers withoutObjCGCAttr() const
bool compatiblyIncludes(Qualifiers other) const
Determines if these qualifiers compatibly include another set.
LangAS getAddressSpace() const
bool compatiblyIncludesObjCLifetime(Qualifiers other) const
Determines if these qualifiers compatibly include another set of qualifiers from the narrow perspecti...
Represents a struct/union/class.
field_range fields() const
static RecoveryExpr * Create(ASTContext &Ctx, QualType T, SourceLocation BeginLoc, SourceLocation EndLoc, ArrayRef< Expr * > SubExprs)
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Base for LValueReferenceType and RValueReferenceType.
static SYCLUniqueStableNameExpr * Create(const ASTContext &Ctx, SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, TypeSourceInfo *TSI)
Scope - A scope is a transient data structure that is used while parsing the program.
unsigned getFlags() const
getFlags - Return the flags for this scope.
@ ContinueScope
This is a while, do, for, which can have continue statements embedded into it.
@ ControlScope
The controlling scope in a if/switch/while/for statement.
@ BreakScope
This is a while, do, switch, for, etc that can have break statements embedded into it.
@ DeclScope
This is a scope that can contain a declaration.
Smart pointer class that efficiently represents Objective-C method names.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
bool isUnarySelector() const
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
A generic diagnostic builder for errors which may or may not be deferred.
RAII class used to indicate that we are performing provisional semantic analysis to determine the val...
Abstract base class used for diagnosing integer constant expression violations.
virtual SemaDiagnosticBuilder diagnoseNotICE(Sema &S, SourceLocation Loc)=0
virtual SemaDiagnosticBuilder diagnoseNotICEType(Sema &S, SourceLocation Loc, QualType T)
virtual SemaDiagnosticBuilder diagnoseFold(Sema &S, SourceLocation Loc)
Sema - This implements semantic analysis and AST building for C.
const FieldDecl * getSelfAssignmentClassMemberCandidate(const ValueDecl *SelfAssigned)
Returns a field in a CXXRecordDecl that has the same name as the decl SelfAssigned when inside a CXXM...
void DefineImplicitLambdaToFunctionPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a function pointer.
ExprResult PerformImplicitConversion(Expr *From, QualType ToType, AssignmentAction Action, bool AllowExplicit=false)
PerformImplicitConversion - Perform an implicit conversion of the expression From to the type ToType.
ObjCMethodDecl * LookupMethodInObjectType(Selector Sel, QualType Ty, bool IsInstance)
LookupMethodInType - Look up a method in an ObjCObjectType.
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
std::optional< ExpressionEvaluationContextRecord::InitializationContext > InnermostDeclarationWithDelayedImmediateInvocations() const
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
void CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS, BinaryOperatorKind Opcode)
Check for comparisons of floating-point values using == and !=.
Scope * getCurScope() const
Retrieve the parser's current scope.
CUDAFunctionTarget IdentifyCUDATarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
const ValueDecl * getOpenMPDeclareMapperVarName() const
bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID, const Ts &... Args)
QualType FindCompositeObjCPointerType(ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
FindCompositeObjCPointerType - Helper method to find composite type of two objective-c pointer types ...
void CheckObjCBridgeRelatedCast(QualType castType, Expr *castExpr)
ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op, Expr *Input, bool IsAfterAmp=false)
ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val)
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr, bool IsAfterAmp=false)
bool isValidRVVBitcast(QualType srcType, QualType destType)
Are the two types RVV-bitcast-compatible types? I.e.
bool isExternalWithNoLinkageType(const ValueDecl *VD) const
Determine if VD, which must be a variable or function, is an external symbol that nonetheless can't b...
void DiagnoseUnusedParameters(ArrayRef< ParmVarDecl * > Parameters)
Diagnose any unused parameters in the given sequence of ParmVarDecl pointers.
ExprResult IgnoredValueConversions(Expr *E)
IgnoredValueConversions - Given that an expression's result is syntactically ignored,...
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupObjCImplicitSelfParam
Look up implicit 'self' parameter of an objective-c method.
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
ExprResult ActOnConstantExpression(ExprResult Res)
QualType CheckLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc, Expr *InitExpr)
bool CheckObjCBridgeRelatedConversions(SourceLocation Loc, QualType DestType, QualType SrcType, Expr *&SrcExpr, bool Diagnose=true)
@ NTCUC_LValueToRValueVolatile
ImplicitConversionSequence TryImplicitConversion(Expr *From, QualType ToType, bool SuppressUserConversions, AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion)
ExprResult BuildLiteralOperatorCall(LookupResult &R, DeclarationNameInfo &SuffixInfo, ArrayRef< Expr * > Args, SourceLocation LitEndLoc, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr)
BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call to a literal operator descri...
bool areVectorTypesSameSize(QualType srcType, QualType destType)
bool isSelfExpr(Expr *RExpr)
Private Helper predicate to check for 'self'.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
ExprResult BuildIvarRefExpr(Scope *S, SourceLocation Loc, ObjCIvarDecl *IV)
void DiagnoseAlwaysNonNullPointer(Expr *E, Expr::NullPointerConstantKind NullType, bool IsEqual, SourceRange Range)
Diagnose pointers that are always non-null.
void DefineImplicitMoveAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared move assignment operator.
void DecomposeUnqualifiedId(const UnqualifiedId &Id, TemplateArgumentListInfo &Buffer, DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *&TemplateArgs)
Decomposes the given name into a DeclarationNameInfo, its location, and possibly a list of template a...
bool InstantiateDefaultArgument(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
void ActOnStartStmtExpr()
ExprResult CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, SourceLocation RLoc, Expr *Base, MultiExprArg Args)
void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec)
Emit a warning for all pending noderef expressions that we recorded.
void ActOnStmtExprError()
DeclResult LookupIvarInObjCMethod(LookupResult &Lookup, Scope *S, IdentifierInfo *II)
The parser has read a name in, and Sema has detected that we're currently inside an ObjC method.
QualType UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, ArithConvKind ACK)
UsualArithmeticConversions - Performs various conversions that are common to binary operators (C99 6....
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(const NamedDecl *D, bool Final=false, const TemplateArgumentList *Innermost=nullptr, bool RelativeToPrimary=false, const FunctionDecl *Pattern=nullptr, bool ForConstraintInstantiation=false, bool SkipForSpecialization=false)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
void CheckPtrComparisonWithNullChar(ExprResult &E, ExprResult &NullE)
NamedDecl * ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II, Scope *S)
ImplicitlyDefineFunction - An undeclared identifier was used in a function call, forming a call to an...
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
unsigned CapturingFunctionScopes
Track the number of currently active capturing scopes.
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, ExpressionEvaluationContextRecord::ExpressionKind Type=ExpressionEvaluationContextRecord::EK_Other)
ObjCMethodDecl * LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R, bool receiverIdOrClass=false)
LookupInstanceMethodInGlobalPool - Returns the method and warns if there are multiple signatures.
ExprResult CheckBooleanCondition(SourceLocation Loc, Expr *E, bool IsConstexpr=false)
CheckBooleanCondition - Diagnose problems involving the use of the given expression as a boolean cond...
bool isOpenMPDeclareMapperVarDeclAllowed(const VarDecl *VD) const
@ Boolean
A boolean condition, from 'if', 'while', 'for', or 'do'.
@ Switch
An integral condition for a 'switch' statement.
@ ConstexprIf
A constant boolean condition from 'if constexpr'.
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
llvm::SmallPtrSet< const Decl *, 4 > ParsingInitForAutoVars
ParsingInitForAutoVars - a set of declarations with auto types for which we are currently parsing the...
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, CorrectionCandidateCallback *CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
bool CheckObjCARCUnavailableWeakConversion(QualType castType, QualType ExprType)
PoppedFunctionScopePtr PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, const Decl *D=nullptr, QualType BlockType=QualType())
Pop a function (or block or lambda or captured region) scope from the stack.
Preprocessor & getPreprocessor() const
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
QualType GetSignedSizelessVectorType(QualType V)
bool CheckCXXThisCapture(SourceLocation Loc, bool Explicit=false, bool BuildAndDiagnose=true, const unsigned *const FunctionScopeIndexToStopAt=nullptr, bool ByCopy=false)
Make sure the value of 'this' is actually available in the current context, if it is a potentially ev...
llvm::SmallPtrSet< ConstantExpr *, 4 > FailedImmediateInvocations
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
DefaultedComparisonKind getDefaultedComparisonKind(const FunctionDecl *FD)
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor,...
void CheckCompleteDestructorVariant(SourceLocation CurrentLocation, CXXDestructorDecl *Dtor)
Do semantic checks to allow the complete destructor variant to be emitted when the destructor is defi...
void MarkCaptureUsedInEnclosingContext(ValueDecl *Capture, SourceLocation Loc, unsigned CapturingScopeIndex)
bool CheckForConstantInitializer(Expr *e, QualType t)
type checking declaration initializers (C99 6.7.8)
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=NoFold)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
Expr * BuildBuiltinCallExpr(SourceLocation Loc, Builtin::ID Id, MultiExprArg CallArgs)
BuildBuiltinCallExpr - Create a call to a builtin function specified by Id.
QualType CheckVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool AllowBothBool, bool AllowBoolConversion, bool AllowBoolOperation, bool ReportInvalid)
type checking for vector binary operators.
LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R, ArrayRef< QualType > ArgTys, bool AllowRaw, bool AllowTemplate, bool AllowStringTemplate, bool DiagnoseMissing, StringLiteral *StringLit=nullptr)
LookupLiteralOperator - Determine which literal operator should be used for a user-defined literal,...
FPOptionsOverride CurFPFeatureOverrides()
bool isValidSveBitcast(QualType srcType, QualType destType)
Are the two types SVE-bitcast-compatible types? I.e.
ExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, bool isAddressOfOperand, const TemplateArgumentListInfo *TemplateArgs)
ActOnDependentIdExpression - Handle a dependent id-expression that was just parsed.
ObjCLiteralKind CheckLiteralKind(Expr *FromE)
void MarkDeclarationsReferencedInExpr(Expr *E, bool SkipLocalVariables=false, ArrayRef< const Expr * > StopAt=std::nullopt)
Mark any declarations that appear within this expression or any potentially-evaluated subexpressions ...
ObjCMethodDecl * LookupMethodInQualifiedType(Selector Sel, const ObjCObjectPointerType *OPT, bool IsInstance)
LookupMethodInQualifiedType - Lookups up a method in protocol qualifier list of a qualified objective...
ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc, unsigned TemplateDepth)
ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, SourceLocation ColonLocSecond, Expr *Length, Expr *Stride, SourceLocation RBLoc)
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallToMemberFunction - Build a call to a member function.
ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E, TypeSourceInfo *TInfo, SourceLocation RPLoc)
FunctionDecl * getCurFunctionDecl(bool AllowLambda=false) const
Returns a pointer to the innermost enclosing function, or nullptr if the current context is not insid...
ExprResult PerformContextualImplicitConversion(SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter)
Perform a contextual implicit conversion.
ExprResult UsualUnaryConversions(Expr *E)
UsualUnaryConversions - Performs various conversions that are common to most operators (C99 6....
ExprResult CheckUnevaluatedOperand(Expr *E)
ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, FunctionDecl *FDecl)
DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but will create a trap if the resul...
void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc)
ExprResult tryConvertExprToType(Expr *E, QualType Ty)
Try to convert an expression E to type Ty.
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy, CastKind &Kind)
QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc)
CheckAddressOfOperand - The operand of & must be either a function designator or an lvalue designatin...
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
ExprResult CheckSwitchCondition(SourceLocation SwitchLoc, Expr *Cond)
static bool TooManyArguments(size_t NumParams, size_t NumArgs, bool PartialOverloading=false)
To be used for checking whether the arguments being passed to function exceeds the number of paramete...
bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy)
QualType InvalidOperands(SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
the following "Check" methods will return a valid/converted QualType or a null QualType (indicating a...
bool DiagIfReachable(SourceLocation Loc, ArrayRef< const Stmt * > Stmts, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the statements's reachability analysis.
QualType CheckShiftOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, bool IsCompAssign=false)
ExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, bool IsAddressOfOperand, const Scope *S, TypeSourceInfo **RecoveryTSI=nullptr)
BuildQualifiedDeclarationNameExpr - Build a C++ qualified declaration name, generally during template...
DiagnosticsEngine & getDiagnostics() const
ExprResult MaybeConvertParenListExprToParenExpr(Scope *S, Expr *ME)
This is not an AltiVec-style cast or or C++ direct-initialization, so turn the ParenListExpr into a s...
bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function, bool Complain=false, SourceLocation Loc=SourceLocation())
Returns whether the given function's address can be taken or not, optionally emitting a diagnostic if...
ExprResult checkPseudoObjectAssignment(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opcode, Expr *LHS, Expr *RHS)
bool CheckCaseExpression(Expr *E)
bool LookupBuiltin(LookupResult &R)
Lookup a builtin function, when name lookup would otherwise fail.
QualType CheckMatrixElementwiseOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Type checking for matrix binary operators.
bool tryToRecoverWithCall(ExprResult &E, const PartialDiagnostic &PD, bool ForceComplain=false, bool(*IsPlausibleResult)(QualType)=nullptr)
Try to recover by turning the given expression into a call.
FunctionDecl * ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, bool Complain, DeclAccessPair &Found, bool *pHadMultipleCandidates=nullptr)
ResolveAddressOfOverloadedFunction - Try to resolve the address of an overloaded function (C++ [over....
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
ExprResult ActOnSourceLocExpr(SourceLocExpr::IdentKind Kind, SourceLocation BuiltinLoc, SourceLocation RPLoc)
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, UnresolvedSetImpl &Functions)
void checkSpecializationReachability(SourceLocation Loc, NamedDecl *Spec)
void CleanupVarDeclMarking()
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
ExprResult BuildSourceLocExpr(SourceLocExpr::IdentKind Kind, QualType ResultTy, SourceLocation BuiltinLoc, SourceLocation RPLoc, DeclContext *ParentContext)
bool isImmediateFunctionContext() const
ASTContext & getASTContext() const
std::unique_ptr< sema::FunctionScopeInfo, PoppedFunctionScopeDeleter > PoppedFunctionScopePtr
ExprResult CallExprUnaryConversions(Expr *E)
CallExprUnaryConversions - a special case of an unary conversion performed on a function designator o...
void translateTemplateArguments(const ASTTemplateArgsPtr &In, TemplateArgumentListInfo &Out)
Translates template arguments as provided by the parser into template arguments used by semantic anal...
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *Input, bool IsAfterAmp=false)
bool tryCaptureVariable(ValueDecl *Var, SourceLocation Loc, TryCaptureKind Kind, SourceLocation EllipsisLoc, bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const unsigned *const FunctionScopeIndexToStopAt)
Try to capture the given variable.
void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var)
Mark a variable referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
void LookupBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, UnresolvedSetImpl &Functions)
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
void DiagnoseUnguardedAvailabilityViolations(Decl *FD)
Issue any -Wunguarded-availability warnings in FD.
void PopExpressionEvaluationContext()
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true, bool AllowRewrittenCandidates=true, FunctionDecl *DefaultedFn=nullptr)
Create a binary operation that may resolve to an overloaded operator.
ExprResult DefaultArgumentPromotion(Expr *E)
DefaultArgumentPromotion (C99 6.5.2.2p6).
bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R, bool HasTrailingLParen)
void InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given variable from its template.
ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *LiteralExpr)
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
DefaultedComparisonKind
Kinds of defaulted comparison operator functions.
@ None
This is not a defaultable comparison operator.
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
FunctionDecl * ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, bool Complain=false, DeclAccessPair *Found=nullptr, TemplateSpecCandidateSet *FailedTSC=nullptr)
Given an expression that refers to an overloaded function, try to resolve that overloaded function ex...
QualType CheckMatrixMultiplyOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
bool isOpenMPGlobalCapturedDecl(ValueDecl *D, unsigned Level, unsigned CaptureLevel) const
Check if the specified global variable must be captured by outer capture regions.
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
void DefineImplicitMoveConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitMoveConstructor - Checks for feasibility of defining this constructor as the move const...
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool PredicateIsExpr, void *ControllingExprOrType, ArrayRef< TypeSourceInfo * > Types, ArrayRef< Expr * > Exprs)
ControllingExprOrType is either a TypeSourceInfo * or an Expr *.
CastKind PrepareCastToObjCObjectPointer(ExprResult &E)
Prepare a conversion of the given expression to an ObjC object pointer type.
ExprResult ActOnUnevaluatedStringLiteral(ArrayRef< Token > StringToks)
void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr, SourceLocation OpLoc)
Warn if a value is moved to itself.
void checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D, SourceLocation IdLoc=SourceLocation())
Check declaration inside target region.
ExprResult PerformOpenMPImplicitIntegerConversion(SourceLocation OpLoc, Expr *Op)
SourceRange getExprRange(Expr *E) const
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
void tryCaptureOpenMPLambdas(ValueDecl *V)
Function tries to capture lambda's captured variables in the OpenMP region before the original lambda...
void DefineImplicitCopyConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitCopyConstructor - Checks for feasibility of defining this constructor as the copy const...
std::optional< ExpressionEvaluationContextRecord::InitializationContext > OutermostDeclarationWithDelayedImmediateInvocations() const
void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID)
DiagnoseUnusedExprResult - If the statement passed in is an expression whose result is unused,...
FPOptions & getCurFPFeatures()
RecordDecl * StdSourceLocationImplDecl
The C++ "std::source_location::__impl" struct, defined in <source_location>.
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK, bool MissingOK=false)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
void CheckTollFreeBridgeCast(QualType castType, Expr *castExpr)
@ UPPC_Block
Block expression.
void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, ArrayRef< Expr * > Args)
DiagnoseSentinelCalls - This routine checks whether a call or message-send is to a declaration with t...
const LangOptions & getLangOpts() const
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
QualType CheckComparisonCategoryType(ComparisonCategoryType Kind, SourceLocation Loc, ComparisonCategoryUsage Usage)
Lookup the specified comparison category types in the standard library, an check the VarDecls possibl...
ExprResult BuildSYCLUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, TypeSourceInfo *TSI)
void DiagnoseInvalidJumps(Stmt *Body)
TypoExpr * CorrectTypoDelayed(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, TypoDiagnosticGenerator TDG, TypoRecoveryCallback TRC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
QualType CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
CastKind PrepareScalarCast(ExprResult &src, QualType destType)
Prepares for a scalar cast, performing all the necessary stages except the final cast and returning t...
QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
bool tryToFixVariablyModifiedVarType(TypeSourceInfo *&TInfo, QualType &T, SourceLocation Loc, unsigned FailedFoldDiagID)
Attempt to fold a variable-sized type to a constant-sized type, returning true if we were successful.
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
void MarkExpressionAsImmediateEscalating(Expr *E)
void ActOnOpenMPIteratorVarDecl(VarDecl *VD)
NonOdrUseReason getNonOdrUseReasonInCurrentContext(ValueDecl *D)
If D cannot be odr-used in the current expression evaluation context, return a reason explaining why.
void DefineDefaultedComparison(SourceLocation Loc, FunctionDecl *FD, DefaultedComparisonKind DCK)
void diagnoseUnavailableAlignedAllocation(const FunctionDecl &FD, SourceLocation Loc)
Produce diagnostics if FD is an aligned allocation or deallocation function that is unavailable.
bool CheckCUDACall(SourceLocation Loc, FunctionDecl *Callee)
Check whether we're allowed to call Callee from the current context.
void MarkFunctionParmPackReferenced(FunctionParmPackExpr *E)
Perform reference-marking and odr-use handling for a FunctionParmPackExpr.
QualType CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType *CompLHSTy=nullptr)
VariadicCallType getVariadicCallType(FunctionDecl *FDecl, const FunctionProtoType *Proto, Expr *Fn)
ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallExpr - Handle a call to Fn with the specified array of arguments.
bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty, SourceLocation OpLoc, SourceRange R)
ActOnAlignasTypeArgument - Handle alignas(type-id) and _Alignas(type-name) .
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
ExprResult checkPseudoObjectIncDec(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opcode, Expr *Op)
Check an increment or decrement of a pseudo-object expression.
void checkTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D=nullptr)
Check if the type is allowed to be used for the current target.
bool areMatrixTypesOfTheSameDimension(QualType srcTy, QualType destTy)
Are the two types matrix types and do they have the same dimensions i.e.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator,...
bool hasCStrMethod(const Expr *E)
Check to see if a given expression could have '.c_str()' called on it.
const LangOptions & LangOpts
std::pair< ValueDecl *, SourceLocation > PendingImplicitInstantiation
An entity for which implicit template instantiation is required.
void EmitRelatedResultTypeNoteForReturn(QualType destType)
Given that we had incompatible pointer types in a return statement, check whether we're in a method w...
ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, TypeSourceInfo *TInfo, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
__builtin_offsetof(type, a.b[123][456].c)
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, ArrayRef< Expr * > Arg, SourceLocation RParenLoc, Expr *Config=nullptr, bool IsExecConfig=false, ADLCallKind UsesADL=ADLCallKind::NotADL)
BuildResolvedCallExpr - Build a call to a resolved expression, i.e.
ExprResult CheckForImmediateInvocation(ExprResult E, FunctionDecl *Decl)
Wrap the expression in a ConstantExpr if it is a potential immediate invocation.
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, CorrectionCandidateCallback &CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr * > Args=std::nullopt, TypoExpr **Out=nullptr)
Diagnose an empty lookup.
ExprResult TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
Expr * stripARCUnbridgedCast(Expr *e)
stripARCUnbridgedCast - Given an expression of ARCUnbridgedCast type, remove the placeholder cast.
void DefineInheritingConstructor(SourceLocation UseLoc, CXXConstructorDecl *Constructor)
Define the specified inheriting constructor.
void CheckUnusedVolatileAssignment(Expr *E)
Check whether E, which is either a discarded-value expression or an unevaluated operand,...
void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D)
@ OperatorInExpression
The '<=>' operator was used in an expression and a builtin operator was selected.
bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid)
Determine whether the use of this declaration is valid, without emitting diagnostics.
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
QualType InvalidLogicalVectorOperands(SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND, SourceLocation Loc)
Emit diagnostics for the diagnose_if attributes on Function, ignoring any ArgDependent DiagnoseIfAttr...
llvm::DenseMap< ParmVarDecl *, SourceLocation > UnparsedDefaultArgLocs
NamedDecl * getCurFunctionOrMethodDecl() const
getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method or C function we're in,...
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, const CXXScopeSpec &SS, QualType T, TagDecl *OwnedTagDecl=nullptr)
Retrieve a version of the type 'T' that is elaborated by Keyword, qualified by the nested-name-specif...
QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2, bool ConvertArgs=true)
Find a merged pointer type and convert the two expressions to it.
SmallVector< std::deque< PendingImplicitInstantiation >, 8 > SavedPendingInstantiations
VarArgKind isValidVarArgType(const QualType &Ty)
Determine the degree of POD-ness for an expression.
bool isQualifiedMemberAccess(Expr *E)
Determine whether the given expression is a qualified member access expression, of a form that could ...
bool isInOpenMPDeclareTargetContext() const
Return true inside OpenMP declare target region.
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, bool AllowBuiltinCreation=false, bool EnteringContext=false)
Performs name lookup for a name that was parsed in the source code, and may contain a C++ scope speci...
static CastKind ScalarTypeToBooleanCastKind(QualType ScalarTy)
ScalarTypeToBooleanCastKind - Returns the cast kind corresponding to the conversion from scalar type ...
void DefineImplicitLambdaToBlockPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a block pointer.
void DefineImplicitDestructor(SourceLocation CurrentLocation, CXXDestructorDecl *Destructor)
DefineImplicitDestructor - Checks for feasibility of defining this destructor as the default destruct...
ExprResult BuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *Ty, SourceLocation RParenLoc, Expr *Op)
sema::FunctionScopeInfo * getCurFunction() const
void checkUnsafeExprAssigns(SourceLocation Loc, Expr *LHS, Expr *RHS)
checkUnsafeExprAssigns - Check whether +1 expr is being assigned to weak/__unsafe_unretained expressi...
ExprResult LookupInObjCMethod(LookupResult &LookUp, Scope *S, IdentifierInfo *II, bool AllowBuiltinCreation=false)
The parser has read a name in, and Sema has detected that we're currently inside an ObjC method.
QualType CheckSizelessVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, ArithConvKind OperationKind)
ExprResult ActOnOpenMPCall(ExprResult Call, Scope *Scope, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig)
Given the potential call expression Call, determine if there is a specialization via the OpenMP decla...
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
Check assignment constraints for an assignment of RHS to LHSType.
void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType, Expr *SrcExpr)
DiagnoseAssignmentEnum - Warn if assignment to enum is a constant integer not in the range of enum va...
llvm::DenseMap< const VarDecl *, int > RefsMinusAssignments
Increment when we find a reference; decrement when we find an ignored assignment.
ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *input, bool RequiresADL=true)
Create a unary operation that may resolve to an overloaded operator.
std::optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
bool findMacroSpelling(SourceLocation &loc, StringRef name)
Looks through the macro-expansion chain for the given location, looking for a macro expansion with th...
bool isConstantEvaluated() const
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitDefaultConstructor - Checks for feasibility of defining this constructor as the default...
void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool PartialOverloading=false)
Add the overload candidates named by callee and/or found by argument dependent lookup to the given ov...
ExprResult DefaultLvalueConversion(Expr *E)
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
ExprResult BuildObjCStringLiteral(SourceLocation AtLoc, StringLiteral *S)
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
void maybeExtendBlockObject(ExprResult &E)
Do an explicit extend of the given block pointer if we're in ARC.
ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool PredicateIsExpr, void *ControllingExprOrType, ArrayRef< ParsedType > ArgTypes, ArrayRef< Expr * > ArgExprs)
ControllingExprOrType is either an opaque pointer coming out of a ParsedType or an Expr *.
void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockError - If there is an error parsing a block, this callback is invoked to pop the informati...
ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr)
Prepare SplattedExpr for a vector splat operation, adding implicit casts if necessary.
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
bool IvarBacksCurrentMethodAccessor(ObjCInterfaceDecl *IFace, ObjCMethodDecl *Method, ObjCIvarDecl *IV)
IvarBacksCurrentMethodAccessor - This routine returns 'true' if 'IV' is an ivar synthesized for 'Meth...
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
@ ForVisibleRedeclaration
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
MaterializeTemporaryExpr * CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference)
ExprResult checkUnknownAnyCast(SourceRange TypeRange, QualType CastType, Expr *CastExpr, CastKind &CastKind, ExprValueKind &VK, CXXCastPath &Path)
Check a cast of an unknown-any type.
SuppressedDiagnosticsMap SuppressedDiagnostics
DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name)
Retrieves the declaration name from a parsed unqualified-id.
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc)
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
void DefineImplicitCopyAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared copy assignment operator.
bool CheckFunctionConstraints(const FunctionDecl *FD, ConstraintSatisfaction &Satisfaction, SourceLocation UsageLoc=SourceLocation(), bool ForOverloadResolution=false)
Check whether the given function decl's trailing requires clause is satisfied, if any.
void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T)
Mark all of the declarations referenced within a particular AST node as referenced.
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5.
DeclContext * getFunctionLevelDeclContext(bool AllowLambda=false) const
If AllowLambda is true, treat lambda as function.
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
@ IncompatiblePointerDiscardsQualifiers
IncompatiblePointerDiscardsQualifiers - The assignment discards qualifiers that we don't permit to be...
@ IntToPointer
IntToPointer - The assignment converts an int to a pointer, which we accept as an extension.
@ IncompatibleBlockPointer
IncompatibleBlockPointer - The assignment is between two block pointers types that are not compatible...
@ IncompatibleObjCQualifiedId
IncompatibleObjCQualifiedId - The assignment is between a qualified id type and something else (that ...
@ IncompatibleVectors
IncompatibleVectors - The assignment is between two vector types that have the same size,...
@ CompatiblePointerDiscardsQualifiers
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
@ IncompatiblePointer
IncompatiblePointer - The assignment is between two pointers types that are not compatible,...
@ IncompatibleObjCWeakRef
IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an object with __weak qualifier.
@ Compatible
Compatible - the types are compatible according to the standard.
@ IncompatibleFunctionPointerStrict
IncompatibleFunctionPointerStrict - The assignment is between two function pointer types that are not...
@ Incompatible
Incompatible - We reject this conversion outright, it is invalid to represent it in the AST.
@ FunctionVoidPointer
FunctionVoidPointer - The assignment is between a function pointer and void*, which the standard does...
@ IncompatibleFunctionPointer
IncompatibleFunctionPointer - The assignment is between two function pointers types that are not comp...
@ IncompatiblePointerSign
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
@ IncompatibleNestedPointerQualifiers
IncompatibleNestedPointerQualifiers - The assignment is between two nested pointer types,...
@ IncompatibleNestedPointerAddressSpaceMismatch
IncompatibleNestedPointerAddressSpaceMismatch - The assignment changes address spaces in nested point...
@ PointerToInt
PointerToInt - The assignment converts a pointer to an int, which we accept as an extension.
@ IntToBlockPointer
IntToBlockPointer - The assignment converts an int to a block pointer.
void CheckShadowingDeclModification(Expr *E, SourceLocation Loc)
Warn if 'E', which is an expression that is about to be modified, refers to a shadowing declaration.
ArithConvKind
Context in which we're performing a usual arithmetic conversion.
@ ACK_Arithmetic
An arithmetic operation.
@ ACK_CompAssign
A compound assignment expression.
@ ACK_BitwiseOp
A bitwise operation.
@ ACK_Conditional
A conditional (?:) operator.
@ ACK_Comparison
A comparison.
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
llvm::PointerIntPair< ConstantExpr *, 1 > ImmediateInvocationCandidate
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
ExprResult TransformToPotentiallyEvaluated(Expr *E)
EnableIfAttr * CheckEnableIf(FunctionDecl *Function, SourceLocation CallLoc, ArrayRef< Expr * > Args, bool MissingImplicitThis=false)
Check the enable_if expressions on the given function.
@ CCK_ImplicitConversion
An implicit conversion.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
SourceManager & getSourceManager() const
@ TryCapture_ExplicitByRef
ExprResult BuildAsTypeExpr(Expr *E, QualType DestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
Create a new AsTypeExpr node (bitcast) from the arguments.
ExprResult checkPseudoObjectRValue(Expr *E)
bool CheckVecStepExpr(Expr *E)
void diagnoseARCUnbridgedCast(Expr *e)
Given that we saw an expression with the ARCUnbridgedCastTy placeholder type, complain bitterly.
ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, SourceLocation ColonLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr)
ActOnConditionalOp - Parse a ?: operation.
QualType CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
CheckVectorCompareOperands - vector comparisons are a clang extension that operates on extended vecto...
QualType CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool IsDivide)
ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr=false)
CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
ExprResult CheckLValueToRValueConversionOperand(Expr *E)
QualType CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType, BinaryOperatorKind Opc)
ExprResult ActOnSYCLUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, ParsedType ParsedTy)
void DiscardMisalignedMemberAddress(const Type *T, Expr *E)
This function checks if the expression is in the sef of potentially misaligned members and it is conv...
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
ExprResult SemaConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
SemaConvertVectorExpr - Handle __builtin_convertvector.
ExprResult ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals.
bool resolveAndFixAddressOfSingleOverloadCandidate(ExprResult &SrcExpr, bool DoFunctionPointerConversion=false)
Given an overloaded function, tries to turn it into a non-overloaded function reference using resolve...
ARCConversionResult CheckObjCConversion(SourceRange castRange, QualType castType, Expr *&op, CheckedConversionKind CCK, bool Diagnose=true, bool DiagnoseCFAudited=false, BinaryOperatorKind Opc=BO_PtrMemD)
Checks for invalid conversions and casts between retainable pointers and other pointer kinds for ARC ...
QualType CheckPointerToMemberOperands(ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, SourceLocation OpLoc, bool isIndirect)
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed.
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, bool AllowExplicitConversion=false, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, ConversionSequenceList EarlyConversions=std::nullopt, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
bool anyAltivecTypes(QualType srcType, QualType destType)
bool isLaxVectorConversion(QualType srcType, QualType destType)
Is this a legal conversion between two types, one of which is known to be a vector type?
void PushBlockScope(Scope *BlockScope, BlockDecl *Block)
sema::FunctionScopeInfo * getCurFunctionAvailabilityContext()
Retrieve the current function, if any, that should be analyzed for potential availability violations.
ExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig, bool AllowTypoCorrection=true, bool CalleesAddressIsTaken=false)
BuildOverloadedCallExpr - Given the call expression that calls Fn (which eventually refers to the dec...
QualType CXXCheckConditionalOperands(ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation questionLoc)
Check the operands of ?: under C++ semantics.
ExprResult BuildAnonymousStructUnionMemberReference(const CXXScopeSpec &SS, SourceLocation nameLoc, IndirectFieldDecl *indirectField, DeclAccessPair FoundDecl=DeclAccessPair::make(nullptr, AS_none), Expr *baseObjectExpr=nullptr, SourceLocation opLoc=SourceLocation())
MaybeODRUseExprSet MaybeODRUseExprs
bool InstantiateInClassInitializer(SourceLocation PointOfInstantiation, FieldDecl *Instantiation, FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiate the definition of a field from the given pattern.
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
bool CheckParmsForFunctionDef(ArrayRef< ParmVarDecl * > Parameters, bool CheckParameterNames)
Helpers for dealing with blocks and functions.
void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl, const LookupResult &R)
Diagnose variable or built-in function shadowing.
ExprResult BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToObjectOfClassType - Build a call to an object of class type (C++ [over....
ExprResult ActOnStringLiteral(ArrayRef< Token > StringToks, Scope *UDLScope=nullptr)
ActOnStringLiteral - The specified tokens were lexed as pasted string fragments (e....
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr)
VarDecl * isOpenMPCapturedDecl(ValueDecl *D, bool CheckScopeInfo=false, unsigned StopAt=0)
Check if the specified variable is used in one of the private clauses (private, firstprivate,...
void checkUnusedDeclAttributes(Declarator &D)
checkUnusedDeclAttributes - Given a declarator which is not being used to build a declaration,...
ExprResult CheckExtVectorCast(SourceRange R, QualType DestTy, Expr *CastExpr, CastKind &Kind)
void setFunctionHasBranchProtectedScope()
ExprResult ActOnOMPArrayShapingExpr(Expr *Base, SourceLocation LParenLoc, SourceLocation RParenLoc, ArrayRef< Expr * > Dims, ArrayRef< SourceRange > Brackets)
bool CheckLoopHintExpr(Expr *E, SourceLocation Loc)
void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, FunctionDecl *Function, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given function from its template.
@ CVT_Host
Emitted on device side with a shadow variable on host side.
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
const DeclContext * getCurObjCLexicalContext() const
bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind, CXXCastPath &BasePath, bool IgnoreBaseAccess, bool Diagnose=true)
CheckPointerConversion - Check the pointer conversion from the expression From to the type ToType.
SmallVector< ExprWithCleanups::CleanupObject, 8 > ExprCleanupObjects
ExprCleanupObjects - This is the stack of objects requiring cleanup that are created by the current f...
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
void NoteAllOverloadCandidates(Expr *E, QualType DestType=QualType(), bool TakingAddress=false)
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)
QualType GetSignedVectorType(QualType V)
QualType CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation QuestionLoc)
Note that LHS is not null here, even if this is the gnu "x ?: y" extension.
ExpressionEvaluationContext
Describes how the expressions currently being parsed are evaluated at run-time, if at all.
@ UnevaluatedAbstract
The current expression occurs within an unevaluated operand that unconditionally permits abstract ref...
@ UnevaluatedList
The current expression occurs within a braced-init-list within an unevaluated operand.
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
@ DiscardedStatement
The current expression occurs within a discarded statement.
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
@ PotentiallyEvaluatedIfUsed
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType, bool IsDereference, SourceRange Range)
ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
__builtin_astype(...)
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc, CallExpr *CE, FunctionDecl *FD)
CheckCallReturnType - Checks that a call expression's return type is complete.
bool CheckUnaryExprOrTypeTraitOperand(Expr *E, UnaryExprOrTypeTrait ExprKind)
Check the constraints on expression operands to unary type expression and type traits.
ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, SourceLocation RPLoc)
TypeSourceInfo * GetTypeForDeclaratorCast(Declarator &D, QualType FromTy)
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
ExprResult forceUnknownAnyToType(Expr *E, QualType ToType)
Force an expression with unknown-type to an expression of the given type.
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
void NoteDeletedInheritingConstructor(CXXConstructorDecl *CD)
QualType getCapturedDeclRefType(ValueDecl *Var, SourceLocation Loc)
Given a variable, determine the type that a reference to that variable will have in the given scope.
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedExpr::IdentKind IK)
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
ExprResult BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr, Expr *IndexExpr, ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod)
Build an ObjC subscript pseudo-object expression, given that that's supported by the runtime.
bool RebuildingImmediateInvocation
Whether the AST is currently being rebuilt to correct immediate invocations.
void DiagnoseAvailabilityOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass, bool ObjCPropertyAccess, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReceiver=nullptr)
void DiscardCleanupsInEvaluationContext()
bool NeedToCaptureVariable(ValueDecl *Var, SourceLocation Loc)
Checks if the variable must be captured.
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, CastKind &Kind)
bool LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS, QualType ObjectType, bool EnteringContext, bool &MemberOfUnknownSpecialization, RequiredTemplateKind RequiredTemplate=SourceLocation(), AssumedTemplateKind *ATK=nullptr, bool AllowTypoCorrection=true)
bool isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level, unsigned OpenMPCaptureLevel) const
Return true if the provided declaration VD should be captured by reference.
SourceManager & SourceMgr
bool CheckAlignasTypeArgument(StringRef KWName, TypeSourceInfo *TInfo, SourceLocation OpLoc, SourceRange R)
ExprResult BuildVectorLiteral(SourceLocation LParenLoc, SourceLocation RParenLoc, Expr *E, TypeSourceInfo *TInfo)
Build an altivec or OpenCL literal.
void checkRetainCycles(ObjCMessageExpr *msg)
checkRetainCycles - Check whether an Objective-C message send might create an obvious retain cycle.
bool isUnavailableAlignedAllocationFunction(const FunctionDecl &FD) const
Determine whether FD is an aligned allocation or deallocation function that is unavailable.
bool DiagnoseDependentMemberLookup(const LookupResult &R)
Diagnose a lookup that found results in an enclosing class during error recovery.
DiagnosticsEngine & Diags
OpenCLOptions & getOpenCLOptions()
NamespaceDecl * getStdNamespace() const
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
void deduceClosureReturnType(sema::CapturingScopeInfo &CSI)
Deduce a block or lambda's return type based on the return statements present in the body.
bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType)
Are the two types lax-compatible vector types? That is, given that one of them is a vector,...
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
void diagnoseMissingTemplateArguments(TemplateName Name, SourceLocation Loc)
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
void DiagnoseAssignmentAsCondition(Expr *E)
DiagnoseAssignmentAsCondition - Given that an expression is being used as a boolean condition,...
void checkSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec)
We've found a use of a templated declaration that would trigger an implicit instantiation.
void EmitRelatedResultTypeNote(const Expr *E)
If the given expression involves a message send to a method with a related result type,...
QualType CheckBitwiseOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
llvm::MapVector< NamedDecl *, SourceLocation > UndefinedButUsed
UndefinedInternals - all the used, undefined objects which require a definition in this translation u...
ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc)
bool ResolveAndFixSingleFunctionTemplateSpecialization(ExprResult &SrcExpr, bool DoFunctionPointerConversion=false, bool Complain=false, SourceRange OpRangeForComplaining=SourceRange(), QualType DestTypeForComplaining=QualType(), unsigned DiagIDForComplaining=0)
ExprResult ConvertParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in it, apply them to D.
void checkVariadicArgument(const Expr *E, VariadicCallType CT)
Check to see if the given expression is a valid argument to a variadic function, issuing a diagnostic...
void CheckStaticArrayArgument(SourceLocation CallLoc, ParmVarDecl *Param, const Expr *ArgExpr)
CheckStaticArrayArgument - If the given argument corresponds to a static array parameter,...
void FilterLookupForScope(LookupResult &R, DeclContext *Ctx, Scope *S, bool ConsiderLinkage, bool AllowInlineNamespace)
Filters out lookup results that don't fall within the given scope as determined by isDeclInScope.
QualType CheckSizelessVectorCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
ExprResult ConvertMemberDefaultInitExpression(FieldDecl *FD, Expr *InitExpr, SourceLocation InitLoc)
bool DiagnoseConditionalForNull(Expr *LHSExpr, Expr *RHSExpr, SourceLocation QuestionLoc)
Emit a specialized diagnostic when one expression is a null pointer constant and the other is not a p...
ExprResult BuildObjCNumericLiteral(SourceLocation AtLoc, Expr *Number)
BuildObjCNumericLiteral - builds an ObjCBoxedExpr AST node for the numeric literal expression.
Expr * FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
void checkNonTrivialCUnionInInitializer(const Expr *Init, SourceLocation Loc)
Emit diagnostics if the initializer or any of its explicit or implicitly-generated subexpressions req...
ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)
ActOnBlockStmtExpr - This is called when the body of a block statement literal was successfully compl...
void DiagnoseDeletedDefaultedFunction(FunctionDecl *FD)
Produce notes explaining why a defaulted function was defined as deleted.
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
bool DiagnoseAssignmentResult(AssignConvertType ConvTy, SourceLocation Loc, QualType DstType, QualType SrcType, Expr *SrcExpr, AssignmentAction Action, bool *Complained=nullptr)
DiagnoseAssignmentResult - Emit a diagnostic, if required, for the assignment conversion type specifi...
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
bool RequireCompleteSizedType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &... Args)
ExprResult ActOnStmtExprResult(ExprResult E)
ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Kind, Expr *Input)
bool GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, const FunctionProtoType *Proto, unsigned FirstParam, ArrayRef< Expr * > Args, SmallVectorImpl< Expr * > &AllArgs, VariadicCallType CallType=VariadicDoesNotApply, bool AllowExplicit=false, bool IsListInitialization=false)
GatherArgumentsForCall - Collector argument expressions for various form of call prototypes.
std::tuple< MangleNumberingContext *, Decl * > getCurrentMangleNumberContext(const DeclContext *DC)
Compute the mangling number context for a lambda expression or block literal.
bool CheckConversionToObjCLiteral(QualType DstType, Expr *&SrcExpr, bool Diagnose=true)
void DiagnoseEqualityWithExtraParens(ParenExpr *ParenE)
Redundant parentheses over an equality comparison can indicate that the user intended an assignment u...
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, const FunctionDecl *FD=nullptr)
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
TypeSourceInfo * GetTypeForDeclarator(Declarator &D, Scope *S)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, MultiExprArg ArgExprs, SourceLocation RLoc)
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc.
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing,...
void DiagnoseUnsatisfiedConstraint(const ConstraintSatisfaction &Satisfaction, bool First=true)
Emit diagnostics explaining why a constraint expression was deemed unsatisfied.
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr)
ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
ExprResult ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, bool IsType, void *TyOrEx, SourceRange ArgRange)
ActOnUnaryExprOrTypeTraitExpr - Handle sizeof(type) and sizeof expr and the same for alignof and __al...
QualType PreferredConditionType(ConditionKind K) const
void clearDelayedTypo(TypoExpr *TE)
Clears the state of the given TypoExpr.
@ LOLR_ErrorNoDiagnostic
The lookup found no match but no diagnostic was issued.
@ LOLR_Raw
The lookup found a single 'raw' literal operator, which expects a string literal containing the spell...
@ LOLR_Error
The lookup resulted in an error.
@ LOLR_Cooked
The lookup found a single 'cooked' literal operator, which expects a normal literal to be built and p...
@ LOLR_StringTemplatePack
The lookup found an overload set of literal operator templates, which expect the character type and c...
@ LOLR_Template
The lookup found an overload set of literal operator templates, which expect the characters of the sp...
void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, Scope *CurScope)
ActOnBlockArguments - This callback allows processing of block arguments.
QualType CheckRemainderOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign=false)
@ Diagnose
Diagnose issues that are non-constant or that are extensions.
sema::CapturedRegionScopeInfo * getCurCapturedRegion()
Retrieve the current captured region, if any.
unsigned getTemplateDepth(Scope *S) const
Determine the number of levels of enclosing template parameters.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
ExprResult ActOnObjCAvailabilityCheckExpr(llvm::ArrayRef< AvailabilitySpec > AvailSpecs, SourceLocation AtLoc, SourceLocation RParen)
bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType)
Helper function to determine whether this is the (deprecated) C++ conversion from a string literal to...
void computeNRVO(Stmt *Body, sema::FunctionScopeInfo *Scope)
Given the set of return statements within a function body, compute the variables that are subject to ...
void checkNonTrivialCUnion(QualType QT, SourceLocation Loc, NonTrivialCUnionContext UseContext, unsigned NonTrivialKind)
Emit diagnostics if a non-trivial C union type or a struct that contains a non-trivial C union is use...
QualType CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, QualType *CompLHSTy=nullptr)
static ConditionResult ConditionError()
ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
__builtin_convertvector(...)
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
HandleFunctionTypeMismatch - Gives diagnostic information for differeing function types.
ExprResult ActOnOMPIteratorExpr(Scope *S, SourceLocation IteratorKwLoc, SourceLocation LLoc, SourceLocation RLoc, ArrayRef< OMPIteratorData > Data)
const TypoExprState & getTypoExprState(TypoExpr *TE) const
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, UnresolvedLookupExpr *AsULE=nullptr)
Builds an expression which might be an implicit member expression.
ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, QualType ¶mType)
Type-check an expression that's being passed to an __unknown_anytype parameter.
bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl, const FunctionProtoType *Proto, ArrayRef< Expr * > Args, SourceLocation RParenLoc, bool ExecConfig=false)
ConvertArgumentsForCall - Converts the arguments specified in Args/NumArgs to the parameter types of ...
ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
OpenMPClauseKind isOpenMPPrivateDecl(ValueDecl *D, unsigned Level, unsigned CapLevel) const
Check if the specified variable is used in 'private' clause.
bool hasAnyUnrecoverableErrorsInThisFunction() const
Determine whether any errors occurred within this function/method/ block.
FullExprArg MakeFullExpr(Expr *Arg)
bool IsFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy)
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noexcept"...
llvm::SmallVector< std::pair< SourceLocation, const BlockDecl * >, 1 > ImplicitlyRetainedSelfLocs
List of SourceLocations where 'self' is implicitly retained inside a block.
bool isOpenMPTargetCapturedDecl(const ValueDecl *D, unsigned Level, unsigned CaptureLevel) const
Check if the specified variable is captured by 'target' directive.
bool CheckAltivecInitFromScalar(SourceRange R, QualType VecTy, QualType SrcTy)
ExprResult HandleExprEvaluationContextForTypeof(Expr *E)
ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
bool isCheckingDefaultArgumentOrInitializer() const
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr, bool SkipImmediateInvocations=true)
Instantiate or parse a C++ default argument expression as necessary.
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
void DiagnoseImmediateEscalatingReason(FunctionDecl *FD)
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
ExprResult CreateBuiltinMatrixSubscriptExpr(Expr *Base, Expr *RowIdx, Expr *ColumnIdx, SourceLocation RBLoc)
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
bool isInSystemMacro(SourceLocation loc) const
Returns whether Loc is expanded from a macro in a system header.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3....
ImplicitConversionKind Second
Second - The second conversion can be an integral promotion, floating point promotion,...
void setAsIdentityConversion()
StandardConversionSequence - Set the standard conversion sequence to the identity conversion.
void setToType(unsigned Idx, QualType T)
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType, bool IgnoreFloatToIntegralConversion=false) const
Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl...
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
StmtClass getStmtClass() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteralParser - This decodes string escape characters and performs wide string analysis and Tra...
StringLiteral - This represents a string literal expression, e.g.
unsigned getLength() const
StringKind
StringLiteral is followed by several trailing objects.
uint32_t getCodeUnit(size_t i) const
static StringLiteral * Create(const ASTContext &Ctx, StringRef Str, StringKind Kind, bool Pascal, QualType Ty, const SourceLocation *Loc, unsigned NumConcatenated)
This is the "fully general" constructor that allows representation of strings formed from multiple co...
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
StringRef getPlatformName() const
Retrieve the name of the platform as it is used in the availability attribute.
@ CharPtrBuiltinVaList
typedef char* __builtin_va_list;
virtual size_t getMaxBitIntWidth() const
virtual bool useFP16ConversionIntrinsics() const
Check whether llvm intrinsics such as llvm.convert.to.fp16 should be used to convert to and from __fp...
unsigned getTypeWidth(IntType T) const
Return the width (in bits) of the specified integer type enum.
uint64_t getPointerWidth(LangAS AddrSpace) const
Return the width of pointers on this target, for the specified address space.
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target,...
IntType getSizeType() const
unsigned getLongLongWidth() const
getLongLongWidth/Align - Return the size of 'signed long long' and 'unsigned long long' for this targ...
bool isTLSSupported() const
Whether the target supports thread-local storage.
virtual bool supportsExtendIntArgs() const
Whether the option -fextend-arguments={32,64} is supported on the target.
virtual BuiltinVaListKind getBuiltinVaListKind() const =0
Returns the kind of __builtin_va_list type that should be used with this target.
bool hasBuiltinMSVaList() const
Returns whether or not type __builtin_ms_va_list type is available on this target.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
unsigned getIntMaxTWidth() const
Return the size of intmax_t and uintmax_t for this target, in bits.
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target,...
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
A convenient class for passing around template argument information.
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
void addArgument(const TemplateArgumentLoc &Loc)
Location wrapper for a TemplateArgument.
Represents a template argument.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a C++ template name within the type system.
Token - This structure provides full information about a lexed token.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
unsigned getLength() const
void setKind(tok::TokenKind K)
tok::TokenKind getKind() const
void setLocation(SourceLocation L)
void startToken()
Reset all flags to cleared.
void setIdentifierInfo(IdentifierInfo *II)
Represents a declaration of a type.
const Type * getTypeForDecl() const
SourceLocation getBeginLoc() const LLVM_READONLY
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
Base wrapper for a particular "section" of type source info.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
void initializeFullCopy(TypeLoc Other)
Initializes this by copying its information from another TypeLoc of the same type.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
SourceRange getLocalSourceRange() const
Get the local source range.
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
void setNameLoc(SourceLocation Loc)
The base class of the type hierarchy.
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isFixedPointOrIntegerType() const
Return true if this is a fixed point or integer type.
bool isBlockPointerType() const
bool isBooleanType() const
bool isObjCBuiltinType() const
bool hasAttr(attr::Kind AK) const
Determine whether this type had the specified attribute applied to it (looking through top-level type...
const Type * getPointeeOrArrayElementType() const
If this is a pointer type, return the pointee type.
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
bool isPlaceholderType() const
Test for a type which does not represent an actual type-system type but is instead used as a placehol...
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
bool isVLSTBuiltinType() const
Determines if this is a sizeless type supported by the 'arm_sve_vector_bits' type attribute,...
bool isConstantArrayType() const
bool canDecayToPointerType() const
Determines whether this type can decay to a pointer type.
bool hasIntegerRepresentation() const
Determine whether this type has an integer representation of some sort, e.g., it is an integer type o...
bool isVoidPointerType() const
const ComplexType * getAsComplexIntegerType() const
bool isFunctionPointerType() const
bool isArithmeticType() const
bool isConstantMatrixType() const
bool isPointerType() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool isSVESizelessBuiltinType() const
Returns true for SVE scalable vector types.
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isSignedFixedPointType() const
Return true if this is a fixed point type that is signed according to ISO/IEC JTC1 SC22 WG14 N1169.
bool isEnumeralType() const
bool isScalarType() const
bool isVariableArrayType() const
bool isSizelessBuiltinType() const
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
bool isObjCQualifiedIdType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool hasUnsignedIntegerRepresentation() const
Determine whether this type has an unsigned integer representation of some sort, e....
bool isExtVectorType() const
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
bool isExtVectorBoolType() const
QualType getSveEltType(const ASTContext &Ctx) const
Returns the representative type for the element of an SVE builtin type.
bool isNonOverloadPlaceholderType() const
Test for a placeholder type other than Overload; see BuiltinType::isNonOverloadPlaceholderType.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isBitIntType() const
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isAnyComplexType() const
bool isFixedPointType() const
Return true if this is a fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169.
bool isSaturatedFixedPointType() const
Return true if this is a saturated fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
const BuiltinType * getAsPlaceholderType() const
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g....
bool isWebAssemblyTableType() const
Returns true if this is a WebAssembly table type: either an array of reference types,...
bool isMemberPointerType() const
bool isAtomicType() const
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
bool isObjCIdType() const
bool isMatrixType() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
bool isComplexIntegerType() const
bool isUnscopedEnumerationType() const
bool isObjCObjectType() const
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
bool isBFloat16Type() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isFunctionType() const
bool isObjCObjectPointerType() const
bool hasFloatingRepresentation() const
Determine whether this type has a floating-point representation of some sort, e.g....
bool isUnsignedFixedPointType() const
Return true if this is a fixed point type that is unsigned according to ISO/IEC JTC1 SC22 WG14 N1169.
bool isVectorType() const
bool isObjCQualifiedClassType() const
bool isObjCClassType() const
bool isRealFloatingType() const
Floating point categories.
bool isRVVSizelessBuiltinType() const
Returns true for RVV scalable vector types.
bool isFloatingType() const
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
bool isAnyPointerType() const
TypeClass getTypeClass() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isNullPtrType() const
bool isRecordType() const
std::optional< NullabilityKind > getNullability() const
Determine the nullability of the given type.
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Simple class containing the result of Sema::CorrectTypo.
IdentifierInfo * getCorrectionAsIdentifierInfo() const
std::string getAsString(const LangOptions &LO) const
SourceRange getCorrectionRange() const
void WillReplaceSpecifier(bool ForceReplacement)
DeclClass * getCorrectionDeclAs() const
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
bool isOverloaded() const
NamedDecl * getFoundDecl() const
Get the correction declaration found by name lookup (before we looked through using shadow declaratio...
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Expr * getSubExpr() const
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode.
static UnaryOperator * Create(const ASTContext &C, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)
bool isIncrementDecrementOp() const
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
Represents a C++ unqualified-id that has been parsed.
void setImplicitSelfParam(const IdentifierInfo *Id)
Specify that this unqualified-id is an implicit 'self' parameter.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
CXXRecordDecl * getNamingClass()
Retrieve the naming class of this lookup.
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
A set of unresolved declarations.
A set of unresolved declarations.
Represents a call to the builtin function __builtin_va_arg.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
bool isWeak() const
Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr.
VarDecl * getPotentiallyDecomposedVarDecl()
Represents a variable declaration or definition.
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
bool isStaticDataMember() const
Determines whether this is a static data member.
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
bool mightBeUsableInConstantExpressions(const ASTContext &C) const
Determine whether this variable's value might be usable in a constant expression, according to the re...
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template,...
bool isInline() const
Whether this variable is (C++1z) inline.
const Expr * getInit() const
bool hasExternalStorage() const
Returns true if a variable has extern or private_extern storage.
bool isARCPseudoStrong() const
Determine whether this variable is an ARC pseudo-__strong variable.
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
@ TLS_None
Not a TLS variable.
@ DeclarationOnly
This declaration is only a declaration.
DefinitionKind hasDefinition(ASTContext &) const
Check whether this variable is defined in this translation unit.
bool isUsableInConstantExpressions(const ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
bool isLocalVarDeclOrParm() const
Similar to isLocalVarDecl but also includes parameters.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization,...
Declaration of a variable template.
Represents a C array with a specified size that is not an integer-constant-expression.
Expr * getSizeExpr() const
Represents a GCC generic vector type.
unsigned getNumElements() const
@ AltiVecBool
is AltiVec 'vector bool ...'
@ RVVFixedLengthDataVector
is RISC-V RVV fixed-length data vector
@ SveFixedLengthPredicateVector
is AArch64 SVE fixed-length predicate vector
@ GenericVector
not a target-specific vector type
@ AltiVecPixel
is AltiVec 'vector Pixel'
@ SveFixedLengthDataVector
is AArch64 SVE fixed-length data vector
@ AltiVecVector
is AltiVec vector
@ NeonVector
is ARM Neon vector
VectorKind getVectorKind() const
QualType getElementType() const
Policy getDefaultPolicy()
Retains information about a block that is currently being parsed.
Scope * TheScope
TheScope - This is the scope for the block itself, which contains arguments etc.
QualType FunctionType
BlockType - The function type of the block, if one was given.
ValueDecl * getVariable() const
bool isBlockCapture() const
SourceLocation getLocation() const
Retrieve the location at which this variable was captured.
void markUsed(bool IsODRUse)
bool isThisCapture() const
QualType getCaptureType() const
Retrieve the capture type for this capture, which is effectively the type of the non-static data memb...
bool isCopyCapture() const
Retains information about a captured region.
unsigned short OpenMPLevel
unsigned short CapRegionKind
The kind of captured region.
unsigned short OpenMPCaptureLevel
void addVLATypeCapture(SourceLocation Loc, const VariableArrayType *VLAType, QualType CaptureType)
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
SmallVector< Capture, 4 > Captures
Captures - The captures.
ImplicitCaptureStyle ImpCaptureStyle
unsigned CXXThisCaptureIndex
CXXThisCaptureIndex - The (index+1) of the capture of 'this'; zero if 'this' is not captured.
bool HasImplicitReturnType
Capture & getCXXThisCapture()
Retrieve the capture of C++ 'this', if it has been captured.
llvm::DenseMap< ValueDecl *, unsigned > CaptureMap
CaptureMap - A map of captured variables to (index+1) into Captures.
bool isCXXThisCaptured() const
Determine whether the C++ 'this' is captured.
bool isVLATypeCaptured(const VariableArrayType *VAT) const
Determine whether the given variable-array type has been captured.
void addCapture(ValueDecl *Var, bool isBlock, bool isByref, bool isNested, SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType, bool Invalid)
Capture & getCapture(ValueDecl *Var)
Retrieve the capture of the given variable, if it has been captured already.
Retains information about a function, method, or block that is currently being parsed.
void recordUseOfWeak(const ExprT *E, bool IsRead=true)
Record that a weak object was accessed.
void markSafeWeakUse(const Expr *E)
Record that a given expression is a "safe" access of a weak object (e.g.
bool FoundImmediateEscalatingExpression
Whether we found an immediate-escalating expression.
void addBlock(const BlockDecl *BD)
void setHasBranchProtectedScope()
llvm::SmallVector< AddrLabelExpr *, 4 > AddrLabels
The set of GNU address of label extension "&&label".
bool HasOMPDeclareReductionCombiner
True if current scope is for OpenMP declare reduction combiner.
SourceRange IntroducerRange
Source range covering the lambda introducer [...].
void addPotentialCapture(Expr *VarExpr)
Add a variable that might potentially be captured by the lambda and therefore the enclosing lambdas.
void addPotentialThisCapture(SourceLocation Loc)
CXXRecordDecl * Lambda
The class that describes the lambda.
unsigned NumExplicitCaptures
The number of captures in the Captures list that are explicit captures.
bool AfterParameterList
Indicate that we parsed the parameter list at which point the mutability of the lambda is known.
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
bool Mutable
Whether this is a mutable lambda.
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Attr > attr
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
bool isa(CodeGen::Address addr)
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
@ OR_Success
Overload resolution succeeded.
bool isTargetAddressSpace(LangAS AS)
DeclContext * getLambdaAwareParentOfDeclContext(DeclContext *DC)
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
NullabilityKind
Describes the nullability of a particular type.
@ Nullable
Values of this type can be null.
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
@ NonNull
Values of this type can never be null.
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
@ OK_VectorComponent
A vector component is an element or range of elements on a vector.
@ OK_ObjCProperty
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
@ OK_Ordinary
An ordinary object is located at an address in memory.
@ OK_BitField
A bitfield object is a bitfield on a C or C++ record.
@ OK_MatrixComponent
A matrix component is a single element of a matrix.
@ IK_ImplicitSelfParam
An implicit 'self' parameter.
@ IK_TemplateId
A template-id, e.g., f<int>.
std::optional< ComparisonCategoryType > getComparisonCategoryForBuiltinCmp(QualType T)
Get the comparison category that should be used when comparing values of type T.
ActionResult< Decl * > DeclResult
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
ObjCMethodFamily
A family of Objective-C methods.
unsigned toTargetAddressSpace(LangAS AS)
@ InternalLinkage
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
@ C
Languages that the frontend can parse and compile.
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
bool isLambdaCallOperator(const CXXMethodDecl *MD)
@ Result
The result type of a method or function.
ImplicitConversionKind
ImplicitConversionKind - The kind of implicit conversion used to convert an argument to a parameter's...
@ ICK_Complex_Conversion
Complex conversions (C99 6.3.1.6)
@ ICK_Integral_Conversion
Integral conversions (C++ [conv.integral])
@ ICK_Floating_Integral
Floating-integral conversions (C++ [conv.fpint])
@ ICK_Array_To_Pointer
Array-to-pointer conversion (C++ [conv.array])
@ ICK_Identity
Identity conversion (no conversion)
@ ICK_Lvalue_To_Rvalue
Lvalue-to-rvalue conversion (C++ [conv.lval])
@ ICK_Floating_Conversion
Floating point conversions (C++ [conv.double].
@ ICK_Complex_Real
Complex-real conversions (C99 6.3.1.7)
@ ICK_Function_To_Pointer
Function-to-pointer (C++ [conv.array])
LangAS
Defines the address space values used by the address space qualifier of QualType.
CastKind
CastKind - The kind of operation required for a conversion.
OverloadedOperatorKind getRewrittenOverloadedOperator(OverloadedOperatorKind Kind)
Get the other overloaded operator that the given operator can be rewritten into, if any such operator...
@ TNK_Var_template
The name refers to a variable template whose specialization produces a variable.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
bool isPtrSizeAddressSpace(LangAS AS)
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
const char * getTraitSpelling(ExpressionTrait T) LLVM_READONLY
Return the spelling of the type trait TT. Never null.
@ NK_Not_Narrowing
Not a narrowing conversion.
@ NK_Constant_Narrowing
A narrowing conversion, because a constant expression got narrowed.
@ NK_Dependent_Narrowing
Cannot tell whether this is a narrowing conversion because the expression is value-dependent.
@ NK_Type_Narrowing
A narrowing conversion by virtue of the source and destination types.
@ NK_Variable_Narrowing
A narrowing conversion, because a non-constant-expression variable might have got narrowed.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
U cast(CodeGen::Address addr)
llvm::omp::Clause OpenMPClauseKind
OpenMP clauses.
ActionResult< Expr * > ExprResult
bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD)
NonOdrUseReason
The reason why a DeclRefExpr does not constitute an odr-use.
@ NOUR_Discarded
This name appears as a potential result of a discarded value expression.
@ NOUR_Unevaluated
This name appears in an unevaluated operand.
@ NOUR_None
This is an odr-use.
@ NOUR_Constant
This name appears as a potential result of an lvalue-to-rvalue conversion that is a constant expressi...
Represents an element in a path from a derived class to a base class.
The class facilities generation and storage of conversion FixIts.
OverloadFixItKind Kind
The type of fix applied.
bool tryToFixConversion(const Expr *FromExpr, const QualType FromQTy, const QualType ToQTy, Sema &S)
If possible, generates and stores a fix for the given conversion.
std::vector< FixItHint > Hints
The list of Hints generated so far.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
void setCXXLiteralOperatorNameLoc(SourceLocation Loc)
setCXXLiteralOperatorNameLoc - Sets the location of the literal operator name (not the operator keywo...
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
SourceLocation getEndLoc() const LLVM_READONLY
EvalResult is a struct with detailed info about an evaluated expression.
APValue Val
Val - This is the value the expression can be folded to.
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
bool HasSideEffects
Whether the evaluated expression has side effects.
Extra information about a function prototype.
FunctionType::ExtInfo ExtInfo
Iterator definition representation.
SourceLocation AssignmentLoc
SourceLocation SecondColonLoc
Helper expressions and declaration for OMPIteratorExpr class for each iteration space.
Expr * CounterUpdate
Updater for the internal counter: ++CounterVD;.
Expr * Upper
Normalized upper bound.
Expr * Update
Update expression for the originally specified iteration variable, calculated as VD = Begin + Counter...
VarDecl * CounterVD
Internal normalized counter.
bool HasFormOfMemberPointer
OverloadExpr * Expression
@ DefaultFunctionArgumentInstantiation
We are instantiating a default argument for a function.
Data structure used to record current or nested expression evaluation contexts.
SmallVector< Expr *, 2 > VolatileAssignmentLHSs
Expressions appearing as the LHS of a volatile assignment in this context.
llvm::SmallPtrSet< const Expr *, 8 > PossibleDerefs
bool isUnevaluated() const
llvm::SmallPtrSet< DeclRefExpr *, 4 > ReferenceToConsteval
Set of DeclRefExprs referencing a consteval function when used in a context not already known to be i...
llvm::SmallVector< ImmediateInvocationCandidate, 4 > ImmediateInvocationCandidates
Set of candidates for starting an immediate invocation.
enum clang::Sema::ExpressionEvaluationContextRecord::ExpressionKind ExprContext
SmallVector< LambdaExpr *, 2 > Lambdas
The lambdas that are present within this context, if it is indeed an unevaluated context.
ExpressionKind
Describes whether we are in an expression constext which we have to handle differently.
MaybeODRUseExprSet SavedMaybeODRUseExprs
CleanupInfo ParentCleanup
Whether the enclosing context needed a cleanup.
unsigned NumTypos
The number of typos encountered during this expression evaluation context (i.e.
bool isConstantEvaluated() const
ExpressionEvaluationContext Context
The expression evaluation context.
bool InImmediateEscalatingFunctionContext
unsigned NumCleanupObjects
The number of active cleanup objects when we entered this expression evaluation context.
Data structure for iterator expression.
Abstract class used to diagnose incomplete types.
Location information for a TemplateArgument.